关于cocos2dx中动画的整理

前端之家收集整理的这篇文章主要介绍了关于cocos2dx中动画的整理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.瞬时动作:CCActionInstant

CCPlace 用于定位

CCHide / CCShow 隐藏和显示

CCToggleVisibility 交替变化换是否为隐藏状态

CCFlipX / CCFlipY分别为水平翻转和垂直翻转


---------------------瞬时动画

auto _place = Place::create(ccp(50,50));
s->runAction(_place);


auto _flipX = CCFlipX::create(true);
s->runAction(_flipX);


auto _flipY = CCFlipY::create(true);
s->runAction(_flipY);


auto _hide = CCHide::create();
s->runAction(_hide);


auto _show = CCShow::create();
s->runAction(_show);


auto toggle = CCToggleVisibility::create();
s->runAction(toggle);

---------------------------------------------------------------------

2.ActionInterval:延时动作

CCMoveTo / CCMoveBy

CCJumpTo / CCJumpBy

CCBezierTo / CCBezierBy

CCScaleTo / CCScaleBy

CCRotateTo / CCRotateBy

闪烁:CCBlink

色调变化:CCTintTo / CCTintBy

变暗到:CCFadeTo

淡出:CCFadeIn

渐隐:CCFadeOut

---------

auto mby = CCMoveBy::create(10,ccp(winsize.width/2,winsize.height/2));
s->runAction(mby);


auto tin = CCTintTo::create(1,255,0);
s->runAction(tin);


auto _fadeout = CCFadeOut::create(1);
auto _delay = DelayTime::create(2);
auto _fadeto = CCFadeTo::create(1,255);
auto sequence = Sequence::create(_fadeout,_delay,_fadeto,NULL);
s->runAction(sequence);


auto _jump = CCJumpTo::create(14,50),10,3);
auto _scaleBy = CCScaleBy::create(1,0.5);
auto _scaleBack = _scaleBy->reverse();
auto _rot = CCRotateTo::create(1,180);
auto blink = CCBlink::create(5,5);
auto _squence = CCSequence::create(_scaleBy,_scaleBack,_rot,blink,NULL);
s->runAction(Spawn::create(_jump,_squence,NULL));

-------------------------------

3.组合动作

序列:CCSequence

同步:CCSpawn

重复有限次:CCRepeat

反动作:Reverse

无限重复:CCRepeatForever

帧动画:CCAnimate

-----------------

auto *s = Sprite::create("grossini_dance_07.png");
s->setPosition(ccp(winsize.width/2,winsize.height/2));
this->addChild(s);


auto _fadeout = CCFadeOut::create(1);
auto _fadein = CCFadeIn::create(1);
auto _sequence = CCSequence::create(_fadeout,_fadein,NULL);
auto _forever = CCRepeatForever::create(_sequence);
s->runAction(_forever);


auto frameCount = 9;
Vector<SpriteFrame *> frameArray;
char str[50];
for (int i=1; i<=frameCount; i++){
sprintf_s(str,"grossini_dance_%02d.png",i);
auto frame = SpriteFrame::create(str,CCRect(0,85,121));
frameArray.pushBack(frame);
}
auto animation = Animation::createWithSpriteFrames(frameArray,0.2);
auto animate = Animate::create(animation);
s->runAction(RepeatForever::create(animate));

return true;

--------------------------------------

EaseIn 由慢至快。
EaSEOut 由快至慢
EaseInOut 由慢至快再由快至慢。
EaseSineIn 由慢至快。
EaseSineOut 由快至慢
EaseSineInOut 由慢至快再由快至慢。
EaseExponentialIn由慢至极快。
EaseExponentialOut 由极快至慢。
EaseExponentialInOut 由慢至极快再由极快至慢。
Speed 人工设定速度,还可通过 SetSpeed 不断调整。

猜你在找的Cocos2d-x相关文章