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

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

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

Body.<init>介绍

[英]Constructs a new body with the given address
[中]

代码示例

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

@Override
  protected Body newObject () {
    return new Body(World.this, 0);
  }
};

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

/** Create a rigid body given a definition. No reference to the definition is retained.
 * @warning This function is locked during callbacks. */
public Body createBody (BodyDef def) {
  org.jbox2d.dynamics.BodyDef bd = new org.jbox2d.dynamics.BodyDef();
  bd.active = def.active;
  bd.allowSleep = def.allowSleep;
  bd.angle = def.angle;
  bd.angularDamping = def.angularDamping;
  bd.angularVelocity = def.angularVelocity;
  bd.awake = def.awake;
  bd.bullet = def.bullet;
  bd.fixedRotation = def.fixedRotation;
  bd.gravityScale = def.gravityScale;
  bd.linearDamping = def.linearDamping;
  bd.linearVelocity.set(def.linearVelocity.x, def.linearVelocity.y);
  bd.position.set(def.position.x, def.position.y);
  if (def.type == BodyType.DynamicBody) bd.type = org.jbox2d.dynamics.BodyType.DYNAMIC;
  if (def.type == BodyType.StaticBody) bd.type = org.jbox2d.dynamics.BodyType.STATIC;
  if (def.type == BodyType.KinematicBody) bd.type = org.jbox2d.dynamics.BodyType.KINEMATIC;
  org.jbox2d.dynamics.Body b = world.createBody(bd);
  Body body = new Body(this, b);
  bodies.put(b, body);
  return body;
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d

@Override
  protected Body newObject () {
    return new Body(World.this, 0);
  }
};

相关文章