Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
About the Author
About the Reviewers

Pulse on unit combine

When our units combine, nothing special really happens. So, what we're going to do is add a slight pulse effect. Basically, when two units combine we want the unit to grow in a fashion similar to the button visual we just created (where it expands and then scales down again).


You can also do fancy things in general when the units spawn, such as particle effects (for example, a subtle explosion/burst effect), sprite animations, and other various things.

The key to polishing is thinking out of the box, yet looking at things you already have within the game to keep the aesthetic consistent and solid.

To carry out the pulsing we desire, since we'll most likely be placing the same code in multiple places, let's create a method that takes in a CCNode object and applies the effect we have in mind. So in MainScene.m, add the following method somewhere in the code (preferably near the combination code):

  CGFloat baseScale = 1.0f;