How to invoke a method at the end of an action?

Hi,

I am creating a sequence of actions (MoveTo, RotateBy, etc.) and at the end of the sequence I would like a method called so that I can do some work. Is there an action I can use to put at the end of the sequence to call my method?

Dominique

In v3.6 you add this as an action to the sequence:

CallFunc::create(bind(&MyClass::methodToCall, this)

And “this” is the instance of MyClass. :wink:

You can add a CallFuncN in your sequence.
something like that:

auto sq = Sequence::create(moveToAction,rotateByAction,etc...,CallFuncN::create(...), nullptr);

Thanks! Can this be used with a lambda?

Yup

Check out the programmer’s guide

Here u go…

sprite->runAction(Sequence::create( ScaleTo::create(0.5f, 1.5f),
              FadeOut::create(0.2f), CallFunc::create( [&,temp]() { 
  temp->removeFromParentAndCleanup(true); 
  }), NULL));

404 on link

My bad.
I fixed it now.
Thanks :+1: