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.
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.
#import "GestureLine.h" #import "GestureShapeLayer.h" @implementation Ch2_Gestures -(CCLayer*) runRecipe { //Init message message = [CCLabelBMFont labelWithString:@"Draw a rectangle, triangle, circle or line" fntFile:@"eurostile_30.fnt"]; message.position = ccp(200,270); message.scale = 0.65f; [message setColor...