1

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
4

2 回答 2

1

仅在加载添加时才显示免费游戏按钮。从适用于 iOS 6.1.3 的 revmob 获得此修复

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

}
于 2013-05-25T03:35:03.593 回答
0

您可以通过以下方式将 UIButton 添加到 Cocos2D 场景中:

CGSize winSize = [[CCDirector sharedDirector] winSize];
CGFloat width = floorf(winSize.width*.8);
CGFloat height = 80;
CGFloat offset = floorf((winSize.width*.8 - width)/2);

UIButton *button = [[RevMobAds session] button];
button.frame = CGrectMake(offset,offset,height,width);
[[[CCDirector sharedDirector] view] addSubview:button];

请注意,它将存在于您的所有 Cocos2D 节点上。

于 2013-05-23T19:44:10.533 回答