No matching function for call to 'cocos2d::Sprite::runAction(cocos2d::Sequence&)

No matching function for call to 'cocos2d::Sprite::runAction(cocos2d::Sequence&)
0.0 0

#1

Hi I’m working on cocos2dx 3.12 version I’m getting following error

error: no matching function for call to 'cocos2d::Sprite::runAction(cocos2d::Sequence&)

In header file I declare void nextHead(float dt); function and a sprite DevilHead1.

I write in init method

this->schedule(schedule_selector(HelloWorld::nextHead), 4.1f);

And I write nextHead function outside the init function as follows-

void HelloWorld::nextHead(float dt)
{
HelloWorld::nodeAction = MoveBy::create( 4.0, Vec2( 330, 100 ) );
	HelloWorld::randomHead = cocos2d::random(0, 7);
	switch(0)
	{
	case 0:
		EaseQuinticActionInOut *  easeAction = EaseQuinticActionInOut::create( HelloWorld::nodeAction );
		HelloWorld::seqHead1 = Sequence::create(easeAction,easeAction,easeAction, nullptr);
		HelloWorld::DevilHead1->runAction(HelloWorld::seqHead1);
break;
}

} 

Getting error at line HelloWorld::DevilHead1->runAction(HelloWorld::seqHead1);

error:no matching function for call to 'cocos2d::Sprite::runAction(cocos2d::Sequence&)' HelloWorld::DevilHead1->runAction(HelloWorld::seqHead1);

Please tell me how to solve it.


#2

Problem solved.
Sorry it was my mistake.

I forget to add * before seqHead1 in header file.

But Now error is not coming and it compiles successfully but it get crashed when nextHead function is called after 4.1 second.

Thanks.


#3

I do it like this:

sprite->scheduleOnce(schedule_selector(CornSprite::delayTimer), 
            sprite->getTimeUntilPop() + 1);
sprite->scheduleOnce(schedule_selector(CornSprite::changeTexture), 
            sprite->getTimeUntilPop() - 2);
sprite->scheduleOnce(schedule_selector(CornSprite::addMore), 
            sprite->getTimeUntilPop() - 2);

and then:

void CornSprite::changeTexture(float dt)
{
    setSpriteFrame("corn6.png");
}

void CornSprite::delayTimer(float dt)
{
    cocos2d::Director::getInstance()->getEventDispatcher()->removeEventListenersForTarget(this);
    
    setSpriteFrame(getPopcornFileName().c_str());
    
    runAction(cocos2d::ScaleBy::create(0.2, 1.5, 1.5));
    
    CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("pop.mp3");

    addMoreSprites(1);
    
    scheduleOnce(schedule_selector(CornSprite::removeSprite), 1.2);
}

void CornSprite::addMore(float dt)
{
    addMoreSprites(1);
}

#4

Hi there,

Thanks for your response. I like your suggestion. I’ll try it.

Thank you.


#5

How did you make out with this?


#6

Hi, Now I’m using MoveTo and MoveBy method’s functionality. To achive my goal.

Problem was coming because of EaseQuinticActionInOut .

Thanks.