Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding sprites to your game


A sprite is just a two-dimensional image used in the game. A sprite can represent a player character, an enemy, or even a background image. The following is a sample of a sprite:

The player character sprite

A sprite can represent a tiny player character that is moved and animated, but at the same time, a sprite can be just a static image that we use to cover the whole background. The following is an example of this:

A background sprite

As you can see, sprites can come in different shapes and sizes depending on what they represent on the screen.

In Cocos2D, a sprite is represented by the CCSprite class that we already used in the past when we displayed the earth image on the screen in the HelloWorld project. The CCSprite class has everything you need to load the sprite image from the disk, position it, and draw it on the screen.

Let's start by adding a background image to our game scene.