0
votes

I have an SKAction:
SKAction *myAction = [SKAction performSelector:@selector(methodA) onTarget:self];

I want to repeat this action 50 times before calling methodB upon completion of the 50 actions.

[[self runAction:[SKAction repeatAction:myAction count:50]  
withKey:@"myActionKey"]   
 completion:^{
        [self methodB];
    }];

It is giving me a bad receiver type 'void' error. The error goes away if I take out the withKey:@"myActionKey" part but I need to get the key because I might need to call removeActionForKey:@"myActionKey" at some point.

Is there any way to work around this?

1

1 Answers

1
votes

The command you are going for does not exist but you can do this:

SKAction *callMethodA = [SKAction runBlock:^{
    [self methodA];
}];

SKAction *myAction = [SKAction repeatAction:callMethodA count:50];

SKAction *callMethodB = [SKAction runBlock:^{
    [self methodB];
}];

SKAction *sequence = [SKAction sequence:@[myAction, callMethodB]];

[self runAction:sequence withKey:@"myKey"];