0

SpriteKit 相当于这样的东西是什么?

[CCNode schedule:@selector(doActivate)
        interval:[[enemyData objectForKey:@"spawnTime"] floatValue]];
4

2 回答 2

3

您可以使用 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

每次通话之间的延迟

于 2013-10-31T18:53:47.987 回答
0

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];
于 2014-03-28T12:54:11.007 回答