I want to run a RepeatForever action on a sprite, but I want to run an initial Action on it first.
I’ve tried putting the initial Action inside a Sequence, followed by a CallFunc that assigns the RepeatForever action.
Sprite *sprite;
...
sprite = Sprite::create(...);
RepeatForever *repeatingAction = RepeatForever::create(...);
FiniteTimeAction *startAction = ...
CallFunc *switchToRepatingAction = CallFunc::create([&]()
{
sprite->runAction(repeatingAction);
});
Sequence *startSequence = Sequence::create(startAction, switchToRepatingAction, nullptr);
sprite->runAction(startSequence);
I get a EXC_BAD_ACCESS error though when I get to sprite->runAction(repeatingAction) inside switchToRepatingAction’s lambda.
I’ll note that this is happening inside the init method of a Node subclass of which sprite is a member variable.
Is it also true that I can’t put a RepeatForever action directly inside a Sequence, even if I put it at the very end? I just tried doing this and my game locked up after the sprite ran startAction.