0

我正在和引擎中开发游戏,我想对我的 Sprite 应用力。问题是我用控制器旋转精灵,我希望在精灵面对的方向上施加力(精灵是火箭)。

提前感谢希望我解释得很好。

4

2 回答 2

0

我用这个找到了朝向

currentVelocity = new Vector2((float)Math.cos(body.getAngle()) * magnitude, (float) Math.sin(body.getAngle()) * magnitude);
    body.applyForce(currentVelocity, body.getPosition());

幅度是一个浮点变量。

于 2013-10-25T18:37:50.530 回答
0
  Sprite  pSprite = new Sprite(23, 43, pTextureRegion, pVertexBufferObject);
    PhysicsHandler handler = new PhysicsHandler(pSprite);
    handler.setVelocityX(pVelocityX);
   handler.setVelocityY(pVelocityY);

这样就可以实现了。如果它没有调整,那么您可以为该特定精灵创建身体并向该身体施加力

于 2013-10-25T04:51:52.113 回答