本文整理了Java中org.jbox2d.dynamics.Body.getLinearVelocity()
方法的一些代码示例,展示了Body.getLinearVelocity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getLinearVelocity()
方法的具体详情如下:
包路径:org.jbox2d.dynamics.Body
类名称:Body
方法名:getLinearVelocity
[英]Get the linear velocity of the center of mass. Do not modify, instead use #setLinearVelocity(Vec2).
[中]得到质心的线速度。不要修改,而是使用#setLinearVelocity(Vec2)。
代码示例来源:origin: libgdx/libgdx
public Vector2 getLinearVelocity () {
Vec2 lv = body.getLinearVelocity();
linearVelocity.set(lv.x, lv.y);
return linearVelocity;
}
代码示例来源:origin: stackoverflow.com
smileyBody.setLinearVelocity(pAccelerationData.getX() * 2, smileyBody.getLinearVelocity().y);
代码示例来源:origin: jbox2d/jbox2d
@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.");
}
代码示例来源:origin: jbox2d/jbox2d
@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();
}
}
代码示例来源:origin: jbox2d/jbox2d
@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);
}
}
}
代码示例来源:origin: jbox2d/jbox2d
@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));
}
代码示例来源:origin: stackoverflow.com
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());
}
}
代码示例来源:origin: org.jbox2d/jbox2d-testbed
private void dampenLiquid() {
for (int i=0; i<liquid.length; ++i) {
Body b = liquid[i];
b.setLinearVelocity(b.getLinearVelocity().mul(0.995f));
}
}
代码示例来源:origin: org.jbox2d/jbox2d-testbed
@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.");
}
代码示例来源:origin: org.jbox2d/jbox2d-testbed
@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();
}
}
代码示例来源:origin: jbox2d/jbox2d
builder.setLinearVelocity(vecToPb(argBody.getLinearVelocity()));
builder.setAngularVelocity(argBody.getAngularVelocity());
builder.setLinearDamping(argBody.getLinearDamping());
代码示例来源:origin: org.jbox2d/jbox2d-testbed
@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);
}
}
}
代码示例来源:origin: stackoverflow.com
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){
内容来源于网络,如有侵权,请联系作者删除!