繁体   English   中英

在cocos2d应用中,标签和按钮在屏幕上从左到右的动画

[英]Animation of label and buttons on the screen from left to right side in cocos2d app

目前,我正在寻找cocos2d游戏应用程序。 我想在游戏完成后在屏幕上显示从左向右滑动的分数,并在屏幕上显示从右向左滑动的按钮,当游戏完成并且分数将显示在分数屏幕上显示给用户。

您可以将标签移动,也可以将按钮从左向右移动,您可以使用以下代码:

在.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];

    }
}

对Button(ccmenuItem)进行相同操作也希望此帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM