需要启用触摸
self.isTouchEnabled=YES;
单只触摸调用:
-(void)ccTounchesBegan:(NSSet *)touches withEvent:(UIEvent*)event;
移动调用:
-(void)ccTounchesMoved:(NSSet *)touches withEvent:(UIEvent*)event;
结束调用:
-(void)ccTounchesEnded:(NSSet *)touches withEvent:(UIEvent*)event;
在很多情况下,需要知道触摸在什么位置发生:
-(CGPoint)locationFromTouches:(NSSet *)touches{
UITouch *touch=[touches anyObject];
CGPoint touchLocation=[touch locationInView : [touch view]];
return [[CCDirector sharedDirector] convertToGL:touchLocation];
}