O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including touches

The touch function is different from the gesture functions as the gesture functions are made to recognize a specific gesture. If this gesture is recognized, a certain function pertaining to this gesture is performed.

Touches, on the other hand, are more open ended. You can write your own gesture codes using the touchesBegan, touchesMoved, and touchesEnded functions.

Getting ready

To test out touches, import the hero images from the second chapter's resources folder and import them into the project as we will need them. Also, as we don't require the gesture functions and initializers, either delete the codes for gesture, or just comment the lines to avoid interference with the touch's function.

How to do it…

To recognize touches, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required