質問

is there a way to put UIView by converting it to EAGLView or should i have to add CAlayer ? whats the best way to do it? any Example codes related to BuzzCity for Cocos2d would be nice

what i have found till now----

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

what i am trying is to display ad on button image... and call the url for ad on buttonAction
how to display this button on top of my uiview?

documentation of buzzCity ad integration http://docs.buzzcity.net/wiki/IOS_SDK#Advanced_Integration_using_BuzzCity_iOS_SDK

役に立ちましたか?

解決

you can not sandwich UIViews between two cocos nodes. If you want an ad button, display the ad as background of a UIButton, or simply make the ad "touchable" by testing if touch location is within ad's frame.

他のヒント

first i saved my image to documents directory

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

}

then i added that path to **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);

finally on button action open the 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];
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top