在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);
好了,加入'anim-> setDelayPerUnit(1);'似乎解决了问题。任何人都可以解释为什么DelayPerUnit和持续时间有什么不同? – Ben 2012-08-08 21:39:01