public Vector2 getLinearVelocity () { Vec2 lv = body.getLinearVelocity(); linearVelocity.set(lv.x, lv.y); return linearVelocity; }
smileyBody.setLinearVelocity(pAccelerationData.getX() * 2, smileyBody.getLinearVelocity().y);
@Override public void step(TestbedSettings settings) { Vec2 v = m_character.getLinearVelocity(); v.x = -5f; super.step(settings); addTextLine("This tests various character collision shapes"); addTextLine("Limitation: square and hexagon can snag on aligned boxes."); addTextLine("Feature: edge chains have smooth collision inside and out."); }
@Override public void step(TestbedSettings settings) { super.step(settings); if (m_break) { Break(); m_broke = true; m_break = false; } // Cache velocities to improve movement on breakage. if (m_broke == false) { m_velocity.set(m_body1.getLinearVelocity()); m_angularVelocity = m_body1.getAngularVelocity(); } }
@Override public void step(TestbedSettings settings) { super.step(settings); addTextLine("Keys: (d) dynamic, (s) static, (k) kinematic"); // Drive the kinematic body. if (m_platform.getType() == BodyType.KINEMATIC) { Vec2 p = m_platform.getTransform().p; Vec2 v = m_platform.getLinearVelocity(); if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) { v.x = -v.x; m_platform.setLinearVelocity(v); } } }
@Override public void step(TestbedSettings settings) { super.step(settings); Vec2 p = circle.getTransform().p; Vec2 v = circle.getLinearVelocity(); if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) { v.x = -v.x; circle.setLinearVelocity(v); } int[] flagsBuffer = m_world.getParticleFlagsBuffer(); for (int i = 0; i < m_world.getParticleCount(); i++) { flagsBuffer[i] = flags; } addTextLine("'a' Clear"); addTextLine("'e' Elastic " + ((flags & ParticleType.b2_elasticParticle) != 0)); addTextLine("'q' Powder " + ((flags & ParticleType.b2_powderParticle) != 0)); addTextLine("'t' Tensile " + ((flags & ParticleType.b2_tensileParticle) != 0)); addTextLine("'v' Viscous " + ((flags & ParticleType.b2_viscousParticle) != 0)); }
public void beginContact(Contact contact) { Body a = contact.getFixtureA().getBody(); Body b = contact.getFixtureB().getBody(); if (a == mBall) { a.setUserData(a.getLinearVelocity().len()); } else if (b == mBall) { b.setUserData(b.getLinearVelocity().len()); } }
private void dampenLiquid() { for (int i=0; i<liquid.length; ++i) { Body b = liquid[i]; b.setLinearVelocity(b.getLinearVelocity().mul(0.995f)); } }
@Override public void step(TestbedSettings settings) { Vec2 v = m_character.getLinearVelocity(); v.x = -5f; super.step(settings); addTextLine("This tests various character collision shapes"); addTextLine("Limitation: square and hexagon can snag on aligned boxes."); addTextLine("Feature: edge chains have smooth collision inside and out."); }
@Override public void step(TestbedSettings settings) { super.step(settings); if (m_break) { Break(); m_broke = true; m_break = false; } // Cache velocities to improve movement on breakage. if (m_broke == false) { m_velocity.set(m_body1.getLinearVelocity()); m_angularVelocity = m_body1.getAngularVelocity(); } }
builder.setLinearVelocity(vecToPb(argBody.getLinearVelocity())); builder.setAngularVelocity(argBody.getAngularVelocity()); builder.setLinearDamping(argBody.getLinearDamping());
@Override public void step(TestbedSettings settings) { super.step(settings); addTextLine("Keys: (d) dynamic, (s) static, (k) kinematic"); // Drive the kinematic body. if (m_platform.getType() == BodyType.KINEMATIC) { Vec2 p = m_platform.getTransform().p; Vec2 v = m_platform.getLinearVelocity(); if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) { v.x = -v.x; m_platform.setLinearVelocity(v); } } }
body.applyForce(new Vector2(0,-SensorManager.GRAVITY_EARTH), new Vector2(body.getWorldCenter())); float vx = body.getLinearVelocity().x, vy = body.getLinearVelocity().y, vr=(float) Math.sqrt(vx*vx+vy*vy); float t= (float) Math.atan(Math.abs(vy/vx)); if(vr<destroyerVelocity){