【发布时间】:2011-02-28 08:23:09
【问题描述】:
我正在使用 cocos2d。如何在 ccTouchesMoved 中获得最后一次联系?
【问题讨论】:
标签: objective-c cocos2d-iphone touch
我正在使用 cocos2d。如何在 ccTouchesMoved 中获得最后一次联系?
【问题讨论】:
标签: objective-c cocos2d-iphone touch
在你的 ccTouchesBegan 中添加一个全局变量,
CGPoint touchPoint = [touch locationInView:[touch view]];
startPosition = [[CCDirector sharedDirector] convertToGL:touchPoint];
在您的 ccTouchesMoved 中,只需使用 startPosition 来检查您的手是否移动
【讨论】:
- (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];
}
你可以这样做:)
【讨论】: