我正在使用cocos2d。如何在ccTouchesMoved中获得最后的触摸?
答案 0 :(得分:1)
在ccTouchesBegan中添加全局变量
CGPoint touchPoint = [touch locationInView:[touch view]];
startPosition = [[CCDirector sharedDirector] convertToGL:touchPoint];
在你的ccTouchesMoved中,只需使用startPosition检查你的手是否移动
答案 1 :(得分:0)
- (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];
}
你可以这样做:)