Reputation: 21
Why animation from the line 2 appears as an error "Function 'animation' cannot be resolved" ?
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);
Upvotes: 0
Views: 209
Reputation: 469
try this code:
sprite->setPosition(ccp(450,425));
this->addChild(sprite, -1);
// after this code
sprite->runAction(CCAnimate::create(anim));
Upvotes: 0
Reputation: 2267
You seem to be using older code with newer cocos2d-x version. Please replace animation() with create().
Upvotes: 1