Game Development Reference
In-Depth Information
SKAction* spaceShipCollectingAnimation = [SKAction
sequence:scaleSequenceAnimations];
However, for coins, a complex one with three actions is created, which are as follows:
FadeOutAction to fade the coin for 0.4 seconds, which appears to be disap-
pearing.
SKAction* coinFadeOutAnimation = [SKAction
fadeOutWithDuration:0.4];
ScaleDownAction to scale down the coin to make it shrink into the spaceship
in 0.4 seconds.
SKAction* scaleDownAnimation = [SKAction
scaleTo:0.2 duration:0.4];
• A CallBack function that is used to remove the coin from the scene when the
preceding animations are over.
SKAction* coinAnimationFinishedCallBack = [SKAction
customActionWithDuration:0.0 actionBlock:^(SKNode
*node,CGFloat elapsedTime)
{
[node removeFromParent];
}];
After creation of all these actions, a group of fadeOut and scaleDown , a sequence of
animation with a sequence of group animation and callback action is created, which is ap-
plied on the coin.
Whenever there is a collision, the spaceship scales up and down with the coin fading out
as depicted in the following screenshot:
Search WWH ::




Custom Search