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 :)
精彩评论