gpt4 book ai didi

ios - cocos2d 中的 Revmob 更多游戏按钮

转载 作者:行者123 更新时间:2023-11-29 13:13:01 27 4
gpt4 key购买 nike

您好,我在游戏中使用了 revmob。我已经集成了全屏,但我无法调用更多游戏屏幕。我有 CCMenuItemImage 并且在它的选择器上我调用了

[RevMobAds openAdLinkWithAppID:@"000000000000000"];

打开itunes。但我想调用 [[RevMobAds session] button]; 但在 revmob 文档上它被分配给按钮,在 cocos2d 中我没有按钮我正在使用 CCMenuItemImage。 Link

这就是它的工作原理。 (官方文档)

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

最佳答案

仅在加载添加时显示免费游戏按钮。从适用于 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" ];

}

关于ios - cocos2d 中的 Revmob 更多游戏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16722385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com