關於cocos2dx中動畫的整理

2021-06-26 18:06:16 字數 2868 閱讀 5269

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,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, ccp(winsize.width/2,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;

vectorframearray;

char str[50];

for (int i=1; i<=framecount; i++)

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中的動畫類

ccsprite pothersprite ccsprite create coin.png pothersprite setanchorpoint ccp 0,0 this addchild pothersprite pothersprite runaction ccplace create cc...

關於cocos2dx中tableView的一些理解

先看 h檔案中 ifndef helloworld scene h define helloworld scene h include cocos2d.h include cocos ext.h using ns cc using ns cc ext class helloworld public ...

cocos2dx動畫Animation介紹

一 幀動畫 cpp ccanimation animation ccanimation create 從本地檔案 系統中載入檔案到ccspriteframe中區,然後新增到ccanimation中 for int i 1 i 15 i sprintf szimagefilename,images g...