0

有没有办法把UIView它转换成EAGLView或者我应该添加CAlayer?最好的方法是什么?BuzzCity任何与for相关的示例代码Cocos2d都会很好

到现在为止我发现的——

btnAD = [CCMenuItemImage itemFromNormalImage:@"underwater-images-paradox-visual-wallpapers-title-search-196522.jpg" selectedImage:@"underwater-images-paradox-visual-wallpapers-title-search-196522.jpg" target:self selector:@selector(AdbuttonAction)];
btnAD.position=ccp(0, 0);

我正在尝试在按钮图像上显示广告...并在buttonAction
上调用广告的 url 如何在我的顶部显示此按钮uiview

BuzzCity 广告集成 文档http://docs.buzzcity.net/wiki/IOS_SDK#Advanced_Integration_using_BuzzCity_iOS_SDK

4

2 回答 2

0

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

于 2013-05-18T09:08:14.590 回答
0

首先,我将图像保存到文档目录

- (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);

最后在按钮操作上打开网址

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