我正在尝试将动画从转换cocos2d
为cocos2d-x
但无济于事。我没有收到任何明显的错误消息,只是它出现在倒数第二行。
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("swim_male.plist");
CCSpriteBatchNode *sceneSpriteBatchNode = CCSpriteBatchNode::batchNodeWithFile("swim_male.png");
this->addChild(sceneSpriteBatchNode);
CCAnimation* animation = CCAnimation::animation();
animation->setDelayPerUnit(.05f);
char* fn = new char;
for (int i = 1; i <= 10; i++) {
sprintf(fn, "character_Male00%02d.png", i);
CCSpriteFrame* pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fn);
animation->addSpriteFrame(pFrame);
}
CCSprite *spriteAnim = CCSprite::spriteWithSpriteFrameName("character_Male0001.png");
spriteAnim->setPosition( ccp(100, 200) );
CCAnimate *animate = CCAnimate::actionWithAnimation(animation);
CCAction *act = CCRepeatForever::actionWithAction(animate);
spriteAnim->runAction(act);
sceneSpriteBatchNode->addChild(spriteAnim, 2);