Performing gestures

Gestures can act as functional input shortcuts. Simple gestures like swiping and scrolling are built into many Apple UI tools. Some games, notably Castlevania: Dawn of Sorrow (DS) and Okami (PS2, Wii) use gestures as core gameplay mechanics. In this recipe, we will implement a simple and admittedly crude gesture system.

Performing gestures

Getting ready

Please refer to the project RecipeCollection01 for full working code of this recipe. Also note that the GestureLine and GestureShapeLayer classes have been omitted for brevity. GestureLine simply contains two CGPoint structures. GestureShapeLayer draws a circle or an array of lines.

How to do it... ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.