本人在使用精灵表单创建动画的过程中突然遇到了一些个问题,下面进行一下分析总结。
根据在Cocos2d-iphone中的经验,我写出了如下的代码:
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("my.plist");
CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("my.png");
this->addChild(batchNode);
CCArray *frameArray = CCArray::create();
for (int i=1; i<=4; i++) {
CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("switch_off_1_%d.png",i)->getCString());
frameArray->addObject(frame);
}
CCAnimation *animation = CCAnimation::create(frameArray, 0.4);
CCAnimate *animate = CCAnimate::create(animation);
CCSprite *iconSprit