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); }
@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; }
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); }
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); }
@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(); } }
public void resetPhysics () { body.setAngularVelocity(0); body.setLinearVelocity(0, 0); impacts = 0; }
@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); }
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);