开发者

How to get last touch in ccTouchesMoved?

I'm working with cocos2d. How to get last touch in ccTouchesMove开发者_开发知识库d?


Add a global Variable in your ccTouchesBegan,

CGPoint touchPoint = [touch locationInView:[touch view]];
startPosition = [[CCDirector sharedDirector] convertToGL:touchPoint];

in your ccTouchesMoved just use startPosition to check whether your hand moved


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[touches allObjects] objectAtIndex: 0];
    // The last location you touch
    CGPoint lastLocation = [touch previousLocationInView:self.view];
    // Current location
    CGPoint currentLocation = [touch locationInView:self.view]; 
}

You can do like that :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜