在 cocos2d-x 中,以下动画代码显示精灵但不运行动画。我究竟做错了什么?
// create a CCAnimation node
CCAnimation * anim = CCAnimation::animation();
// add the images to the loop (one image per frame)
anim->addSpriteFrameWithFileName("Hero/1.png");
anim->addSpriteFrameWithFileName("Hero/2.png");
anim->addSpriteFrameWithFileName("Hero/3.png");
// create an action
CCAnimate * animation = CCAnimate::actionWithAnimation( anim );
animation->setDuration(0.5);
CCAction * repeat = CCRepeatForever::actionWithAction(animation);
// create a sprite to run the action
CCSprite * test = CCSprite::create("Hero/1.png");
test->setPosition( ccp( 150, 150 ) );
test->runAction( repeat );
this->addChild( test );