Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocos2d iphone 如何在cocos2d项目中显示广告横幅(buzzcity)?_Cocos2d Iphone_Admob_Eaglview_Adbannerview - Fatal编程技术网

Cocos2d iphone 如何在cocos2d项目中显示广告横幅(buzzcity)?

Cocos2d iphone 如何在cocos2d项目中显示广告横幅(buzzcity)?,cocos2d-iphone,admob,eaglview,adbannerview,Cocos2d Iphone,Admob,Eaglview,Adbannerview,有没有办法将UIView转换为EAGLView来放置它,或者我应该添加CAlayer? 最好的方法是什么? 任何与BuzzCity相关的Cocos2d示例代码都很好 到现在为止我发现了什么---- 我正在尝试的是在按钮图像上显示广告。。。 并在按钮操作中调用广告的url 如何在myuiview顶部显示此按钮 buzzCity广告集成文档 您不能在两个cocos节点之间夹心UIView。如果您想要广告按钮,请将广告显示为UIButton的背景,或者通过测试触摸位置是否在广告框内,使广告“可触摸”。

有没有办法将
UIView
转换为
EAGLView
来放置它,或者我应该添加
CAlayer
? 最好的方法是什么? 任何与
BuzzCity
相关的
Cocos2d
示例代码都很好

到现在为止我发现了什么----

我正在尝试的是在按钮图像上显示广告。。。 并在按钮操作中调用广告的url
如何在my
uiview
顶部显示此按钮

buzzCity广告集成文档

您不能在两个cocos节点之间夹心UIView。如果您想要广告按钮,请将广告显示为UIButton的背景,或者通过测试触摸位置是否在广告框内,使广告“可触摸”。

首先,我将图像保存到documents目录中

- (NSString *)saveImage {
    NSURL *url = [NSURL   URLWithString:@"http://ads.buzzcity.net/show.php?partnerid=8404&browser=app_apple"];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image = [UIImage imageWithData:data];
      //convert image into .png format.
    NSData *imageData = UIImagePNGRepresentation(image);
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:@"myImage"];
    [imageData writeToFile:fullPath atomically:YES];
    NSLog(@"image saved");
    return fullPath;

}
然后我将该路径添加到
**itemFromNormalImage:fullPath**

NSString *fullPath=[self saveImage];
    btnAD = [CCMenuItemImage itemFromNormalImage:fullPath selectedImage:fullPath target:self selector:@selector(AdButtonAction)];

        NSLog(@"btnAD %@", btnAD);

    CCMenu *adMenu = [CCMenu menuWithItems:btnAD, nil];
    [self addChild:adMenu];
    adMenu.position = ccp(350 ,size.height-50);
最后,打开url的按钮操作

-(void)AdButtonAction
{
  NSURL *url = [NSURL URLWithString:@"http://click.buzzcity.net/click.php?partnerid=8404&browser=app_apple"];
  NSLog(@"url = %@",url);
  [[UIApplication sharedApplication] openURL:url];
}

完成。现在,我可以将包中的图像显示为我的项目的背景图像。问题在于itemFromNormalImage需要nsstring而不是uiimage
-(void)AdButtonAction
{
  NSURL *url = [NSURL URLWithString:@"http://click.buzzcity.net/click.php?partnerid=8404&browser=app_apple"];
  NSLog(@"url = %@",url);
  [[UIApplication sharedApplication] openURL:url];
}