Reputation: 863
What's the SpriteKit equivalent of something like this?
[CCNode schedule:@selector(doActivate)
interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
Upvotes: 0
Views: 208
Reputation: 2114
Schedulers in Cocos:
[self schedule:@selector(doActivate:)
interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
Equivalent in Spritekit using SKAction:
SKAction *wait = [SKAction waitForDuration:[[enemyData objectForKey:@"spawnTime"] floatValue]];
SKAction *performSelector = [SKAction performSelector:@selector(doActivate:) onTarget:self];
SKAction *sequence = [SKAction sequence:@[performSelector, wait]];
SKAction *repeat = [SKAction repeatActionForever:sequence];
[self runAction:repeat];
Upvotes: 0
Reputation: 972
You can use SKAction to do this:
+ (SKAction *)performSelector:(SEL)selector onTarget:(id)target or
+ (SKAction *)runBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue
combined with:
+ (SKAction *)repeatActionForever:(SKAction *)action
and
+ (SKAction *)waitForDuration:(NSTimeInterval)sec
for a delay between each call
Upvotes: 3