ภาพเคลื่อนไหว Sprite นั้นค่อนข้างเรียบง่าย คุณเพียงแค่สร้างCCAnimation
โหนดเพิ่มรูปภาพลงในลูปจากนั้นสร้างแอคชั่นที่ใช้CCAnimate::actionWithDuration(float, CCAnimation, bool)
และทำให้สไปรต์ทำงาน
ตัวอย่าง:
CCAnimation * anim = CCAnimation::animation();
// There are other several ways of storing + adding frames,
// this is the most basic using one image per frame.
anim->addFrameWithFileName("bear1.png");
anim->addFrameWithFileName("bear2.png");
anim->addFrameWithFileName("bear3.png");
anim->addFrameWithFileName("bear4.png");
anim->addFrameWithFileName("bear5.png");
anim->addFrameWithFileName("bear6.png");
anim->addFrameWithFileName("bear7.png");
anim->addFrameWithFileName("bear8.png");
CCAnimate *theAnim = CCAnimate::actionWithDuration(1.8f,anim,true);
// Duration, animation action and bool to return to frame 1 after finishing.
CCSprite *bear = CCSprite::spriteWithFile("bear1.png");
addChild(bear,0); //Don't forget to add any sprite you use as a child to the CCLayer!
bear->runAction(theAnim);