Cocos2D v2.0至v3.x简洁转换指南(二)

来源:互联网 发布:淘宝免单真的假的 编辑:程序博客网 时间:2024/06/06 07:25

触摸处理

我们在稍后将完成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
0 0
原创粉丝点击