1
我正在使用cocos2d。如何獲得最後的觸摸ccTouchesMoved?如何獲得ccTouchesMoved的最後一次觸摸?
我正在使用cocos2d。如何獲得最後的觸摸ccTouchesMoved?如何獲得ccTouchesMoved的最後一次觸摸?
在ccTouchesMoved添加一個全局變量在你ccTouchesBegan,
CGPoint touchPoint = [touch locationInView:[touch view]];
startPosition = [[CCDirector sharedDirector] convertToGL:touchPoint];
只使用指定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];
}
你可以做這樣的:)