Game Development Reference
In-Depth Information
1. After detecting the collision, the spaceShipCollidedWithCoin function is
invoked, which calls two other functions that implement animation methods for
the spaceship and coin that have collided. The definition of this method looks like
this:
- (void)spaceShipCollidedWithCoin:(SKNode*)coinNode
{
[self runSpaceshipCollectingAnimation];
[self runCollectedAnimationForCoin:coinNode];
}
2. The animation written for the spaceship is as if it is taking the coin into itself.
There are two actions created for scaleUp and scaleDown with a scale factor
1.4 and 1.0 respectively to be played for 0.2 each.
- (void)runSpaceshipCollectingAnimation
{
SKAction* scaleUp = [SKAction scaleTo:1.4
duration:0.2];
SKAction* scaleDown = [SKAction scaleTo:1.0
duration:0.2];
}
3. After that, these two animation arrays are formed to be used for creating a se-
quence action.
NSArray* scaleSequenceAnimations =
[NSArray arrayWithObjects:scaleUp, scaleDown, nil];
SKAction* spaceShipCollectingAnimation = [SKAction
sequence:scaleSequenceAnimations];
Search WWH ::




Custom Search