Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d Game Development Blueprints

You're reading from   Cocos2d Game Development Blueprints Design, develop, and create your own successful iOS games using the Cocos2d game engine

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781783987887
Length 440 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jorge Jord√°n Jorge Jord√°n
Author Profile Icon Jorge Jord√°n
Jorge Jord√°n
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Sprites, Sounds, and Collisions 2. Explosions and UFOs FREE CHAPTER 3. Your First Online Game 4. Beat All Your Enemies Up 5. Scenes at the Highest Level 6. Physics Behavior 7. Jump and Run 8. Defend the Tower Index

Creating your first animation


Now that we have a way to load a large amount of images efficiently, we can go further using these images to animate our sprites.

An animation is the simulation of a movement by displaying sequences of static images that will make our brain think that it's looking at a smooth motion.

If you think about it, we already have the knowledge and the tools to create them because for this purpose, we need a sequence of static images that will be displayed in a loop that could be endless or not.

To begin, we need to import the CCAnimation class, so add the following code to the imports section in GameScene.h:

#import "CCAnimation.h"

Now let's declare a constant for the number of frames that will take part in the animation by adding the following lines to GameScene.m after the import section:

// Number of walk animation frames
const int NUM_WALK_FRAMES = 6;

This doesn't need an explanation, as it's just a constant declaration. Now add the following lines at the end of the init...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image