Error create animation with plist file

SpriteFrameCache::getInstance()->addSpriteFramesWithFile("run.plist", "run.png");
const int numberSprite = 5;
auto gameSprite = Sprite::createWithSpriteFrameName("run1.png");
gameSprite->setPosition(300, 300);
this->addChild(gameSprite);
Vector<SpriteFrame*> animFrames;
animFrames.reserve(numberSprite);
animFrames.pushBack(SpriteFrameCache::getInstance()->getSpriteFrameByName("run2.png"));
animFrames.pushBack(SpriteFrameCache::getInstance()->getSpriteFrameByName("run3.png"));
animFrames.pushBack(SpriteFrameCache::getInstance()->getSpriteFrameByName("run4.png"));

Animation* animation = Animation::createWithSpriteFrames(animFrames, 0.5f);
Animate* animate = Animate::create(animation);

gameSprite->runAction(RepeatForever::create(animate));

I received notice like this
fsfe

auto mySprite = Sprite::create("mysprite.png");

// now lets animate the sprite we moved
Vector<SpriteFrame*> animFrames;
animFrames.reserve(12);
animFrames.pushBack(SpriteFrame::create("Blue_Front1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Front2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Front3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right3.png", Rect(0,0,65,81)));

// create the animation out of the frames
Animation* animation = Animation::createWithSpriteFrames(animFrames, 0.1f);
Animate* animate = Animate::create(animation);

// run it and repeat it forever
mySprite->runAction(RepeatForever::create(animate));

This is an example. One thing to note is that your Vector is size 5 and you are adding 3

Also, there may be a more informative message in the console on VS. Perhaps make sure your plist is fine, png’s are named right, etc.

1 Like

thank you …