I have a sprite kit scene in which enemies are dispatched at random intervals and a player has to destroy them. However I want to wait a 3 seconds before they start spawning. I tried

    -(id)initWithSize:(CGSize)size {    
if (self = [super initWithSize:size]) {
    /* Setup your scene here */

    //Set the init variables.
    //AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);

    SKAction *wait = [SKAction waitForDuration:3];
    [self runAction:wait];}

This doesn't work, what am I doing wrong?

有帮助吗?

解决方案

Use completion.

[self runAction:wait completion:^
{ [self startSpawning] }];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top