In my game, I am using SKAction repeatActionForever:
method to periodically call some method with performSelector:
. As I seen, there is no way to stop this. I tried to stop via removeActionForKey:
or removeAllActions
- no results. I don't want to call this action recursively , so I need help.
UPDATE: My SKAction code
levelTimer=[SKAction repeatActionForever:[SKAction sequence:@[[SKAction waitForDuration:30.0],[SKAction performSelector:@selector(moveToNextLevel) onTarget:self]]]];
[self runAction:levelTimer withKey:@"levelTimerAction"];
The repeatActionForever
method should be called on the node which the SKAction
is running on, so:
[sprite removeActionForKey:@"forevercalleraction"];
Assume you add the action like this, and the sprite
variable is not locally added (declared in .h):
[sprite runAction:repeatPerformSelectorAction withKey:@"forevercalleraction"];
To sum the above, check these:
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With