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

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

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

Body.setAngularVelocity介绍

[英]Set the angular velocity.
[中]设置角速度。

代码示例

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

private void launch () {
  m_body.setTransform(new Vector2(0, 20), 0);
  m_angularVelocity = (float)Math.random() * 100 - 50;
  m_body.setLinearVelocity(new Vector2(0, -100));
  m_body.setAngularVelocity(m_angularVelocity);
}

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

@Override
public boolean keyDown (int keyCode) {
  if (keyCode == Keys.D) m_platform.setType(BodyType.DynamicBody);
  if (keyCode == Keys.S) m_platform.setType(BodyType.StaticBody);
  if (keyCode == Keys.K) {
    m_platform.setType(BodyType.KinematicBody);
    m_platform.setLinearVelocity(tmp.set(-m_speed, 0));
    m_platform.setAngularVelocity(0);
  }
  return false;
}

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

public CirclePlatform (int x, int y, float radius, float da) {
  platform = createCircle(BodyType.KinematicBody, radius, 1);
  platform.setTransform(x, y, 0);
  platform.getFixtureList().get(0).setUserData("p");
  platform.setAngularVelocity(da);
  platform.setUserData(this);
}

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

public MovingPlatform (float x, float y, float width, float height, float dx, float dy, float da, float maxDist) {
  platform = createBox(BodyType.KinematicBody, width, height, 1);
  pos.x = x;
  pos.y = y;
  dir.x = dx;
  dir.y = dy;
  this.maxDist = maxDist;
  platform.setTransform(pos, 0);
  platform.getFixtureList().get(0).setUserData("p");
  platform.setAngularVelocity(da);
  platform.setUserData(this);
}

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

@Override
protected void createWorld (World world) {
  {
    BodyDef bd = new BodyDef();
    bd.position.set(0, 0);
    Body body = world.createBody(bd);
    EdgeShape shape = new EdgeShape();
    shape.set(new Vector2(-10, 0), new Vector2(10, 0));
    body.createFixture(shape, 0);
    shape.dispose();
    PolygonShape poly = new PolygonShape();
    poly.setAsBox(0.2f, 1.0f, new Vector2(0.5f, 1.0f), 0);
    body.createFixture(poly, 0);
    poly.dispose();
  }
  {
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DynamicBody;
    bd.position.set(0, 20);
    PolygonShape shape = new PolygonShape();
    shape.setAsBox(2, 0.1f);
    m_body = world.createBody(bd);
    m_body.createFixture(shape, 1);
    m_angularVelocity = 33.468121f;
    m_body.setLinearVelocity(new Vector2(0, -100));
    m_body.setAngularVelocity(m_angularVelocity);
    shape.dispose();
  }
}

代码示例来源:origin: manuelbua/uracer-kotd

public void resetPhysics () {
  body.setAngularVelocity(0);
  body.setLinearVelocity(0, 0);
  impacts = 0;
}

代码示例来源:origin: manuelbua/uracer-kotd

@Override
public void onBeforePhysicsSubstep () {
  super.onBeforePhysicsSubstep();
  // let's subclasses behave as needed, ask them to fill carForces with new data
  onComputeCarForces(carForces);
  // trigger event, new forces have been computed
  if (triggerEvents) {
    GameEvents.playerCar.data.setForces(carForces);
    GameEvents.playerCar.trigger(this, CarEvent.Type.onPhysicsForcesReady);
  }
  // put newly computed forces into the system
  body.setLinearVelocity(carForces.velocity_x, carForces.velocity_y);
  body.setAngularVelocity(-carForces.angularVelocity);
}

代码示例来源:origin: MovingBlocks/box2d-editor

private void restart() {
  bottleModel.setTransform(0, 3, 0.2f);
  bottleModel.setLinearVelocity(0, 0);
  bottleModel.setAngularVelocity(0);
    ballModels[i].setAngularVelocity(0);
    ballModels[i].setTransform(vec.set(tx, ty), angle);

相关文章