com.badlogic.gdx.physics.box2d.Body.getWorldPoint()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中com.badlogic.gdx.physics.box2d.Body.getWorldPoint()方法的一些代码示例,展示了Body.getWorldPoint()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getWorldPoint()方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:getWorldPoint

Body.getWorldPoint介绍

[英]Get the world coordinates of a point given the local coordinates.
[中]获取给定局部坐标的点的世界坐标。

代码示例

代码示例来源:origin: libgdx/libgdx

public boolean keyDown (int keyCode) {
  if (keyCode == Keys.W) {
    Vector2 f = m_body.getWorldVector(tmp.set(0, -200));
    Vector2 p = m_body.getWorldPoint(tmp.set(0, 2));
    m_body.applyForce(f, p, true);
  }
  if (keyCode == Keys.A) m_body.applyTorque(50, true);
  if (keyCode == Keys.D) m_body.applyTorque(-50, true);
  return false;
}

代码示例来源:origin: lycying/c2d-engine

static Vector2 worldPoint(b2BodyDefModel b2, Vector2 localVector) {
    Vector2 tmp = new Vector2();
    try {
      tmp.set(b2.body.getWorldPoint(localVector.cpy().scl(1f / Box2dObject.RADIO))).scl(Box2dObject.RADIO);
    } catch (Exception ex) {
      //
    }
    return tmp;
  }
}

代码示例来源:origin: lycying/c2d-engine

model.localAnchorB.set(0, 0);
final Vector2 worldA = model.bodyA.body.getWorldPoint(model.localAnchorA.cpy().scl(1f / Box2dObject.RADIO)).scl(Box2dObject.RADIO);
final Vector2 worldB = model.bodyB.body.getWorldPoint(model.localAnchorB.cpy().scl(1f / Box2dObject.RADIO)).scl(Box2dObject.RADIO);
if (model.groundAAlignAnchorA) {
  model.groundAnchorA.x = worldA.x;
      model.bodyA.body.getWorldPoint(model.localAnchorA.cpy().scl(1f / Box2dObject.RADIO)).sub(
          model.bodyB.body.getWorldPoint(model.localAnchorB.cpy().scl(1f / Box2dObject.RADIO))
      ).scl(Box2dObject.RADIO).len();
      model.bodyA.body.getWorldPoint(model.localAnchorA.cpy().scl(1f / Box2dObject.RADIO)).sub(
          model.bodyB.body.getWorldPoint(model.localAnchorB.cpy().scl(1f / Box2dObject.RADIO))
      ).scl(Box2dObject.RADIO).len();

相关文章