使用帧cocos2dx动画精灵3.2

时间:2014-08-31 17:27:09

标签: c++ cocos2d-x cocos2d-x-3.0

我的动画无效。它向我展示了我在初始化目标精灵时提到的框架。任何人都可以告诉我,我到底错过了什么?谢谢。

SpriteFrameCache *spriteCache = SpriteFrameCache::getInstance();
spriteCache->addSpriteFramesWithFile("explode.plist", "explosion_rollv2.png");

Vector<SpriteFrame*> frames(22);
for (int i; i<= 22; i++)
{
        CCString *frame_name = CCString::createWithFormat("%d.png",i);
        auto frame = spriteCache->getSpriteFrameByName(frame_name->getCString());
        //frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frame->getCString()));
        frames.pushBack(frame);

}

    auto blast_frame = Animation::createWithSpriteFrames(frames,0.1);
    blast_frame->setRestoreOriginalFrame(true);
    auto blast = Sprite::createWithSpriteFrameName("0.png");
    blast->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2));
    this->addChild(blast,500);

    blast->runAction(RepeatForever::create(Animate::create(blast_frame)));

1 个答案:

答案 0 :(得分:0)

对于所有遇到此问题的人来说,这是一个链接http://www.cocos2d-x.org/wiki/Sprite_Sheet_Animation