0

为什么第 2 行的动画显示为错误“无法解析函数'动画'”?

CCSprite * sprite  = CCSprite::create("start.png");
CCAnimation * anim = CCAnimation::animation();
anim->addSpriteFrameWithFileName("start.png");
anim->addSpriteFrameWithFileName("take.png");
anim->addSpriteFrameWithFileName("action.png");

anim->setLoops(1);
anim->setDelayPerUnit(0.1f);

sprite->runAction(CCAnimate::create(anim));
sprite->setPosition(ccp(450,425));
this->addChild(sprite, -1);
float cX = size.width / sprite->getContentSize().width/1.8;
float cY = size.height / sprite->getContentSize().height/1.2;
sprite->setScaleX(cX);
sprite->setScaleY(cY);
4

2 回答 2

1

您似乎在使用较旧的代码和较新的 cocos2d-x 版本。请用 create() 替换 animation()。

于 2013-10-18T07:56:29.687 回答
0

试试这个代码:

  sprite->setPosition(ccp(450,425));
  this->addChild(sprite, -1);

 // after this code
 sprite->runAction(CCAnimate::create(anim));
于 2014-01-06T18:03:03.800 回答