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

Implementing tap

Tap is a gesture in which you quickly touch and remove the finger from the screen. There is a separate gesture recognizer for this as well.

Getting started

To get ready, no additional work is required.

How to do it…

Similarly to the swipe gesture recognizer, we just have to assign a function that will get called once the gesture is recognized. Add the following code to the class:

UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizeralloc] initWithTarget:self action:@selector(handleTap:)];
[[UIApplicationsharedApplication].delegate.windowaddGestureRecognizer:tapGestureRecognizer];

Here, we will create a variable of the UITapGestureRecognizer type, allocate and initialize it with a function, and set the delegate as ...

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