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

Time for action – adding the player character


Now that we have added the background image, let's add our hunter character. There will be two images, as we're going to split our character in the following two halves:

  • Torso

  • Legs

This will allow us to rotate the torso (the upper body) when aiming. It will get clearer in a moment.

It is a good idea to group these two images into one Cocos2D node to have the ability to operate with both of them as a single game object. Also, we're going to add some code to implement the properties and behavior of our hunter character game object, so we'll need a class for it anyway.

To add the hunter to our game, we need to do the following:

  1. Create a new group for our game objects so that we can separate game object classes from the rest of the classes in the project. Go ahead and create a group called GameObjects next to the Scenes group.

  2. Then, right-click on the GameObjects group and click on the New File… option.

  3. Create a new Objective-C class. Name the class Hunter...