I'm trying to create an animation using a sprite sheet in Cocos2D-x. I'm doing the following. The game doesn't crash but the screen is still blank.
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
auto cacher = SpriteFrameCache::getInstance();
cacher->addSpriteFramesWithFile("BatmanRun-hd.plist");
Sprite* someSprite = Sprite::create();
// load all the animation frames into an array
Vector<SpriteFrame*> frames;
for (int i = 2; i <= 10; i++)
{
stringstream ss;
ss << "run_" << i << ".png";
frames.pushBack(cacher->getSpriteFrameByName(ss.str()));
}
// play the animation
Animation* anim = Animation::createWithSpriteFrames(frames, 0.05f);
someSprite->runAction(Animate::create(anim));
someSprite->setPosition(100, 100);
this->addChild(someSprite);
return true;
}
Is there something I'm missing? Thanks.