Skip to content

Instantly share code, notes, and snippets.

@liu7yong
Created September 17, 2013 03:45
Show Gist options
  • Save liu7yong/6589855 to your computer and use it in GitHub Desktop.
Save liu7yong/6589855 to your computer and use it in GitHub Desktop.
animate each image as a frame (like gif) in cocos2d-x
CCSprite *pSkill = (CCSprite *) getChildByTag(TAG_MENU)->getChildByTag(tag);
CCSprite *pHighLight = CCSprite::createWithSpriteFrameName("point1.png");
this->addChild(pHighLight, Z_ORDER_TITLE, TAG_SKILL_HIGHLIGHT);
pHighLight->setPosition(pSkill->getPosition());
CCArray *walkAnimFrames = CCArray::create();
for (int i = 1; i<= 4; i++)
{
walkAnimFrames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("point%d.png", i)->getCString()));
}
CCAnimation *walkAnim = CCAnimation::createWithSpriteFrames(walkAnimFrames, 0.3f);
pHighLight->runAction(CCRepeatForever::create(CCAnimate::create(walkAnim)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment