cocos2d-iphone – 在cocos2d中实现动画按钮

cocos2d-iphone – 在cocos2d中实现动画按钮,第1张

概述我希望克隆在Candy Crush Saga中发现的按钮动画的效果. 而且我也想知道如何做这样的液体&美丽的动画. 用Cocos2d-iPhone可以吗? 这是Candy Crush Sage的链接: http://www.youtube.com/watch?v=KAMUWIqYN24 是用图像序列完成的吗? 有可能的.只需在按钮普通精灵上运行动画即可. GTAnimSprite *frame_n 我希望克隆在Candy Crush Saga中发现的按钮动画的效果.
而且我也想知道如何做这样的液体&美丽的动画.
用Cocos2d-iPhone可以吗?

这是Candy Crush Sage的链接:

http://www.youtube.com/watch?v=KAMUWIqYN24

是用图像序列完成的吗?

解决方法 有可能的.只需在按钮普通精灵上运行动画即可.

GTAnimsprite *frame_normal   = [GTAnimsprite spriteWithfile:@"play_button_normal.png"];GTAnimsprite *frame_sel     = [GTAnimsprite spriteWithfile:@"play_button_selected.png"];frame_sel.color = ccc3(128,128,128);CcmenuItemSprite *plyBtn = [CcmenuItemSprite itemWithnormalSprite:frame_normal                                          selectedSprite:frame_sel                                                  target:self                                                selector:@selector(playBtnPress:) ];plyBtn.position = ccp(size.wIDth*0.77f,size.height*0.1f);Ccmenu *menu2 = [Ccmenu menuWithItems:plyBtn,nil];menu2.position = ccp(0.0f,0.0f);[self addChild:menu2 z:2 ];

//这是类文件:GTAnimsprite.h

#import <Foundation/Foundation.h>#import "cocos2d.h"@interface GTAnimsprite : CCSprite{    bool bouncing;    float counter;}@end

//这是类文件:GTAnimsprite.mm

#import "GTAnimsprite.h"@implementation GTAnimsprite-(voID)onEnter{    [super onEnter];    counter = 0.0f;    bouncing = true;    [self scheduleUpdate];}-(voID)update:(ccTime)dt{    if (bouncing)    {        counter += dt;        self.scaleX = ( (sin(counter*10) + 1)/2.0 * 0.1 + 1);        self.scaleY = ( (cos(counter*10) + 1)/2.0 * 0.1 + 1);        if (counter > M_PI*10){            counter = 0;        }    }}-(voID)onExit{    [self unscheduleUpdate];    [super onExit];}@end

这里是XCODE样本来源:https://www.box.com/s/52i4xyznetyyc329evcu

总结

以上是内存溢出为你收集整理的cocos2d-iphone – 在cocos2d中实现动画按钮全部内容,希望文章能够帮你解决cocos2d-iphone – 在cocos2d中实现动画按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/999996.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存