Hi i am using revmob in my game . I have integrated full screen but i cant call more games screen. I have CCMenuItemImage and on its selector i have called
[RevMobAds openAdLinkWithAppID:@"000000000000000"];
its opening itunes. But i want to call [[RevMobAds session] button];
but on revmob docs it is assign to button and in cocos2d i dont have Button i am using CCMenuItemImage.
Link
THis is how it works. (Official Doc)
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat width = floorf(self.view.frame.size.width*.8);
CGFloat height = 80;
CGFloat offset = floorf((self.view.frame.size.width*.8 - width)/2);
UIButton *button = [[RevMobAds session] button];
button.frame = CGrectMake(offset,offset,height,width);
[self.view addSubview:button];
// Optional title change
[button setTitle:@"More Free Games" forState:UIControlStateNormal];
// Optional color changes
UIImage *background1 = [self imageWithColor:[UIColor grayColor]];
UIImage *background2 = [self imageWithColor:[UIColor lightGrayColor]];
[button setBackgroundImage:background1 forState:UIControlStateNormal];
[button setBackgroundImage:background2 forState:UIControlStateSelected];
// Optional rounded corner changes, require #import <QuartzCore/QuartzCore.h>
button.layer.cornerRadius = 5;
button.clipsToBounds = YES;
}
@end
Show free game button only if it loads add. Got this fix from revmob for iOS 6.1.3
-(id)init
{
...
...
[self addRevmobButtonAds];
return self;
}
-(void)addRevmobButtonAds
{
RevMobAdLink *ad = [[RevMobAds session] adLink];
[ad loadWithSuccessHandler:^(RevMobAdLink *link)
{
[self showFreeGameButton];
} andLoadFailHandler:^(RevMobAdLink *link, NSError *error) {
}];
}
-(void) showFreeGameButton
{
CCSprite *more_1 = [CCSprite spriteWithSpriteFrameName:@"moreGamebtn.png"];
CCSprite *more_2 = [CCSprite spriteWithSpriteFrameName:@"moreGameSelected.png"];
CCMenuItemSprite *moreBtn = [CCMenuItemSprite itemFromNormalSprite:more_1
selectedSprite:more_2
target:self
selector:@selector(moreBtnPress:) ];
moreBtn.position = ccp(mS.width*0.75f, mS.height*0.145f);
moreBtn.scale = 0.0f;
CCMenu *menu = [CCMenu menuWithItems:moreBtn, plyBtn, nil];
menu.position = ccp(0.0f,0.0f);
[self addChild:menu z:2 ];
}
-(void)moreBtnPress:(id)sender
{
[[RevMobAds session] showPopup];
[[SimpleAudioEngine sharedEngine] playEffect:@"step.wav" ];
}