触摸处理
我们在稍后将完成Cocos2d 3.0中触摸处理的完整教程。而现在最重要的是知道如何去启用触摸处理在你的CCNode中:
self.userInteractionEnabled = TRUE;
去捕捉一个触摸以及触摸的位置:
- (void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLocation = [touch locationInNode:self];
// put your touch handling code here
}
并且知道3个其它方法,它们可以完成确定移动,结束和取消的触摸动作:
- (void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event - (void)touchEnded:(UITouch *)touch withEvent:(UIEvent *)event - (void)touchCancelled:(UITouch *)touch withEvent:(UIEvent *)event