I don't have experience with Sprite Kit. I was wondering is there something similar to Cocos2D schedulers in Sprite Kit ? If no, what should be used NSTimer is the only option? I guess if the only option is using NSTimer we manually need to handle case when application is in background. Thank you.
To achieve functionality similar to cocos scheduler you can use SKAction.
For example for the to achieve something like this
[self schedule:@selector(fireMethod:) interval:0.5];
using SKAction You would write this
SKAction *wait = [SKAction waitForDuration:0.5];
SKAction *performSelector = [SKAction performSelector:@selector(fireMethod:) onTarget:self];
SKAction *sequence = [SKAction sequence:@[performSelector, wait]];
SKAction *repeat = [SKAction repeatActionForever:sequence];
[self runAction:repeat];
It isn't best looking, and lacks some flexibility of CCScheduler, but it will pause upon backgrounding, pausing scene/view etc. + it is like playing with LEGOs :)
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