SpriteKit 相当于这样的东西是什么?
[CCNode schedule:@selector(doActivate)
interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
SpriteKit 相当于这样的东西是什么?
[CCNode schedule:@selector(doActivate)
interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
您可以使用 SKAction 执行此操作:
+ (SKAction *)performSelector:(SEL)selector onTarget:(id)target or
+ (SKAction *)runBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue
结合:
+ (SKAction *)repeatActionForever:(SKAction *)action
和
+ (SKAction *)waitForDuration:(NSTimeInterval)sec
每次通话之间的延迟
Cocos 中的调度器:
[self schedule:@selector(doActivate:)
interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
在 Spritekit 中使用 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];