Book Image

iOS Game Programming Cookbook

Book Image

iOS Game Programming Cookbook

Overview of this book

Table of Contents (19 chapters)
iOS Game Programming Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Applying actions on sprites


Sprites are just static images with no life. So actions add that life to the sprites that make your game. Actions help in building the gameplay by moving sprites and animating them differently. An action is an object that makes the scene look alive.

Actions are applied on nodes and sprites, for example, we want to move some object that is a sprite, so we create a move action and run it on that sprite. SpriteKit automatically changes the sprite's position in a form of animation until the action is over.

All actions are implemented using a class called SKAction and different types of actions are instantiated using the class methods of the SKAction class provided for various animation functionality.

Here are the most common actions available in SpriteKit:

  • Applying transformation (translation, rotation, and scaling)

  • Changing visibility (fading in and fading out)

  • Changing the content of the sprite

  • Changing the colors of sprites

  • Removing sprites

  • Calling a block or a selector...