I'm looking to make a pause on touch for a SprintKit game. When the game is paused a label is shown with PAUSE as text until the user touchUp the screen again to un-pause. When the game un-pauses a countdown from 3 will be displayed prior to the scene being ran again.
it appears that line 7 ([_pauseLabelNode setText:@"2"];) is never triggered by the animation completing, which is strange as I use runAction:completion: elsewhere in the code and that works fine! In order to make this work do i need to over-inflate this by setting up an operation queue in order to control the animation sequence? or have I just made a mistake but am blind to it?
Here is what I have so far:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([self isPaused]) {
[_pauseLabelNode setText:@"3"];
[_pauseLabelNode setScale:1.0];
[_pauseLabelNode runAction:[SKAction scaleTo:0.0 duration:1.0] completion:^{
[_pauseLabelNode setText:@"2"];
[_pauseLabelNode setScale:1.0];
[_pauseLabelNode runAction:[SKAction scaleTo:0.0 duration:1.0] completion:^{
[_pauseLabelNode setText:@"1"];
[_pauseLabelNode setScale:1.0];
[_pauseLabelNode runAction:[SKAction scaleTo:0.0 duration:1.0] completion:^{
[_pauseLabelNode setScale:1.0];
[self setPaused:NO];
[_pauseLabelNode setText:@"GO"];
[_pauseLabelNode runAction:[SKAction scaleTo:0.0 duration:0.5]];
}];
}];
}];
} else {
_pauseLabelNode = [SKLabelNode labelNodeWithFontNamed:@"Papyrus"];
[_pauseLabelNode setHorizontalAlignmentMode:SKLabelHorizontalAlignmentModeCenter];
[_pauseLabelNode setPosition:CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))];
[_pauseLabelNode setFontSize:48.0f];
[_pauseLabelNode setZPosition:100];
[_pauseLabelNode setText:@"Pause"];
[self addChild:_pauseLabelNode];
[self setPaused:YES];
[_pauseLabelNode runAction:[SKAction sequence:@[[SKAction scaleTo:1.5 duration:0.1], [SKAction scaleTo:1.0 duration:0.1]]]];
}