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

Adding rotation objects

The rotation gesture is also a two-finger gesture in which one finger is kept stationary and the second finger is rotated around the other finger in clockwise or anticlockwise motions, resulting in the image rotating in the direction of the motion of the finger.

Getting ready

We will use the same background image to rotate it this time around. Do create a new global float variable called lastRotAngle to keep track of the previous rotated angle as it will be required.

How to do it…

As usual, we will create the rotation gesture, initialize it, and provide the function to update the image. So, in the init function, we will add the following:

// ** rotation ** // UIRotationGestureRecognizer* rotationRecognizer = [[UIRotationGestureRecognizeralloc] ...

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