林在我的應用程序移動精靈與此代碼:Cocos2d:如何在觸摸移動精靈時增加動量?
- (void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
CGPoint newPos = ccpAdd(self.position, translation);
self.position = newPos;
}
它工作正常,但精靈作爲移動取景器是在屏幕上。
我想要實現的是刷卡後的某種動力, 就像iOS中應用程序的內部版本一樣。
任何人都可以給我一個如何做到這一點的暗示嗎?
嘗試b2Mousejoint .. – Guru