關於cocos2d x中的動畫類

2021-09-30 10:43:04 字數 2457 閱讀 9095

ccsprite *pothersprite = ccsprite::create("coin.png");

pothersprite->setanchorpoint(ccp(0,0));

this->addchild(pothersprite);

//pothersprite->runaction(ccplace::create(ccp(300,300)));

//pothersprite->runaction(cchide::create());

//pothersprite->runaction(ccmoveto::create(1,ccp(300,300)));  

pothersprite->runaction(ccjumpto::create(5,ccp(300,300),50,5));  

瞬時動作

瞬時動作不需要時間,立即完成

[cpp]

//放置,=setposition()

prole->runaction(ccplace::create(ccp(300,300)));

//隱藏,=setvisible(false)

prole->runaction(cchide::create());

//顯示,=setvisible(true)

prole->runaction(ccshow::create());

//水平翻轉,=setflipx(true)

prole->runaction(ccflipx::create(true));

//垂直翻轉,=setflipy(true)

prole->runaction(ccflipy::create(true));

延時動作

[cpp]

//移動到,1s,

prole->runaction(ccmoveto::create(1,ccp(300,300)));

//跳躍到,1s,高度50,分為5步

prole->runaction(ccjumpto::create(1,ccp(300,300),50,5));

//放大到,1s,2倍大小

prole->runaction(ccscaleto::create(1,2));

//旋轉到,1s,90度

prole->runaction(ccrotateto::create(1,90));

//閃爍,1s,5下

prole->runaction(ccblink::create(1,5));

//色調製化到,1s,rgb

prole->runaction(cctintto::create(1,100,100,100));

//變暗到,1s,透明度

prole->runaction(ccfadeto::create(1,50));

//由無變亮,1s,

prole->runaction(ccfadein::create(1));

//由亮變無,1s,

prole->runaction(ccfadeout::create(1));

//水平翻轉,1s

prole->runaction(ccflipx3d::create(1));

重複動作

[cpp]

//重複執行

prole->runaction(ccrepeat::create(ccflipx3d::create(1),2));

//無限重複

prole->runaction(ccrepeatforever::create(ccflipx3d::create(1)));

反動作[cpp]

//反動作,通常只有 cc***by支援

prole->runaction(ccsequence::create(ccmoveby::create(1,ccp(50,50)),ccmoveby::create(1,ccp(50,50))->reverse(),null));

連續動作

[cpp]

//連續動作

ccflipx3d* flip3d=ccflipx3d::create(1);

ccblink* blink=ccblink::create(1,2);

ccscaleto* scaleto=ccscaleto::create(1,2);

prole->runaction(ccsequence::create(flip3d,blink ,scaleto,null));

同步動作

[cpp]

//同步動作,確保動作可以同步執行,

ccrotateto* roteto=ccrotateto::create(1,90);

ccfadeto* fadeto=ccfadeto::create(1,50);

prole->runaction(ccspawn::create(roteto,fadeto ,null));  

關於cocos2dx中動畫的整理

1.瞬時動作 ccactioninstant ccplace 用於定位 cchide ccshow 隱藏和顯示 cctogglevisibility 交替變化換是否為隱藏狀態 ccflipx ccflipy分別為水平翻轉和垂直翻轉 瞬時動畫 auto place place create ccp 5...

Cocos2d x動畫工具類

1.此工具類的目的是為了方便執行動畫,使用texturepackergui工具可以匯出plist檔案和png,這裡我示例叫bxjg.plist和bxjg.png h檔案 ifndef animateutil h define animateutil h include cocos2d.h using...

關於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 ...