目前,我正在寻找一个 cocos2d 游戏应用程序。我想在游戏完成后在屏幕上显示从左到右滑动的分数和从右到左滑动的按钮,并且分数将显示在分数屏幕上显示给用户。
问问题
412 次
1 回答
0
你可以移动标签以及按钮从左到右移动你可以使用这个代码: -
在 .h 类中:-
@property(nonatomic,retain)CCLabelTTF *Result_lable;
在 .m 类中:-
@synthesize Result_lable;
-(id)init
{
if (self = [super init])
{
Result_lable = [CCLabelTTF labelWithString:@"lable" fontName:@"Arial" fontSize:24];
Result_lable.position =ccp(160, 280);
[self addChild:Result_lable];
id move1 =[CCMoveBy actionWithDuration:1.0 position:ccp(0, 0)];
id move2 = [CCMoveTo actionWithDuration:1.0 position:ccp(320, 0)];
id repeat = [CCRepeatForever actionWithAction:[CCSequence actions:move1,move2, nil]];
[Result_lable runAction:repeat];
}
}
对按钮(ccmenuItem)做同样的事情也希望这有帮助
于 2013-10-11T08:00:39.007 回答