Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

Table of Contents (15 chapters)
Cocos2d Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

1-star challenge – adding a score label


The goal of platform games is usually overcoming challenges to rescue someone at the end of the game, or picking up coins or another kind of object to beat some record. This will be the purpose of our game: earning as many points as possible.

In this challenge, I want you to add a label in the top-right corner of the screen that will show the points our Yeti has earned so far.

The solution

To implement this challenge, we will basically perform the same changes that we made in Chapter 1, Sprites, Sounds, and Collisions, for the same purpose.

I created a Text (.fnt) bitmap font called font that you will find in the Resources folder. First of all, you need to add some font files to the project, so follow these steps:

  1. In the navigator project, on the left, right-click on the Resources group and select Add Files to "JumpAndRun"….

  2. Look up the font.fnt and font.png files in the Resources folder and select Add.

Then add the following declarations to GameScene.m:

...