Game Development Reference
In-Depth Information
tion are hardcoded in the initial state of the game. All this is set on the basis of
who out of blue and red is the local and remote tank on the device.
11. To animate the players identity text, add a method hideGameInfoLa-
belWithAnimation .
- (void)hideGameInfoLabelWithAnimation
{
SKAction* gameInfoLabelHoldAnimationCallBack =
[SKAction customActionWithDuration:2.0
actionBlock:^(SKNode *node,CGFloat
elapsedTime)
{
}];
SKAction* gameInfoLabelFadeOutAnimation =
[SKAction fadeOutWithDuration:1.0];
SKAction* gameInfoLabelRemoveAnimationCallBack =
[SKAction
customActionWithDuration:0.0actionBlock:^(SKNode
*node,CGFloat elapsedTime)
{
[node removeFromParent];
self.gameInfoLabel = nil;
}];
NSArray* gameLabelAnimationsSequence = [NSArray
arrayWithObjects:gameInfoLabelHoldAnimationCallBack,gameInfoLabelFadeOutAnimation,gameInfoLabelRemoveAnimationCallBack,
nil];
SKAction* gameInfoSequenceAnimation = [SKAction
sequence:gameLabelAnimationsSequence];
[self.gameInfoLabel
runAction:gameInfoSequenceAnimation];
}
12. Using sprite SKAction a sequence of animations is created, having a delay ini-
tially, fading the label and then using a callback to remove it at last. This is done
when the users are connected. For fading in and out of the labels, we use the same
animation code that we used earlier in Chapter 3 , Animations and Texture .
Search WWH ::




Custom Search