还有什么替代mousejoint?

问题描述:

我想为我的播放器提供一个鼠标连接,但我读到它不应该用在这种情况下。我能想到创建它的唯一方法是获取触摸输入的位置,并取走播放器的当前位置,然后将线速度设置为与其相等。你能想到其他方法吗?干杯。还有什么替代mousejoint?

+0

如果鼠标联合工厂,我会说只是用它。 – iforce2d

根据我的说法,更多的xplanation会有所帮助。我建议你可以从你的身体转换到接触点,就像我在我的比赛中一样。

-(void) transFormBodyToPos:(CGPoint) pos{ 
    body->SetTransform(b2Vec2(pos.x/PTM_RATIO, pos.y/PTM_RATIO), 0); 
} 

,并调用它的触摸移动

CGPoint location = [[CCDirector sharedDirector] convertToGL:[touch locationInView:touch.view]]; 
touchLocation = location; 
[classCharacter transFormBodyToPos:touchLocation];