本文整理了Java中com.badlogic.gdx.physics.box2d.Body.setBullet()
方法的一些代码示例,展示了Body.setBullet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.setBullet()
方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:setBullet
[英]Should this body be treated like a bullet for continuous collision detection?
[中]这具尸体应该像子弹一样进行连续碰撞检测吗?
代码示例来源:origin: libgdx/libgdx
private Body createPlayer () {
BodyDef def = new BodyDef();
def.type = BodyType.DynamicBody;
Body box = world.createBody(def);
PolygonShape poly = new PolygonShape();
poly.setAsBox(0.45f, 1.4f);
playerPhysicsFixture = box.createFixture(poly, 1);
poly.dispose();
CircleShape circle = new CircleShape();
circle.setRadius(0.45f);
circle.setPosition(new Vector2(0, -1.4f));
playerSensorFixture = box.createFixture(circle, 0);
circle.dispose();
box.setBullet(true);
return box;
}
代码示例来源:origin: libgdx/libgdx
public void create () {
cam = new OrthographicCamera(48, 32);
cam.position.set(0, 15, 0);
renderer = new Box2DDebugRenderer();
world = new World(new Vector2(0, -10), true);
Body body = world.createBody(new BodyDef());
CircleShape shape = new CircleShape();
shape.setRadius(1f);
MassData mass = new MassData();
mass.mass = 1f;
body.setMassData(mass);
body.setFixedRotation(true);
body.setType(BodyType.KinematicBody);
body.createFixture(shape, 1);
body.setBullet(true);
body.setTransform(new Vector2(0, 0), body.getAngle());
body.setLinearVelocity(new Vector2(50f, 0));
}
代码示例来源:origin: dozingcat/Vector-Pinball
public static Ball create(World world, float x, float y, float radius,
Color primaryColor, Color secondaryColor) {
Body ballBody = Box2DFactory.createCircle(world, x, y, radius, false);
ballBody.setBullet(true);
// Default is radius of 0.5, if different we want the mass to be the same (could be
// configurable if needed), so adjust density proportional to square of the radius.
if (radius != 0.5f) {
ballBody.getFixtureList().get(0).setDensity((0.5f*0.5f) / (radius*radius));
ballBody.resetMassData();
}
return new Ball(ballBody, primaryColor, secondaryColor);
}
代码示例来源:origin: dozingcat/Vector-Pinball
@Override public void createBodies(World world) {
this.anchorBody = Box2DFactory.createCircle(world, this.cx, this.cy, 0.05f, true);
// Joint angle is 0 when flipper is horizontal.
// The flipper needs to be slightly extended past anchorBody to rotate correctly.
float ext = (this.flipperLength > 0) ? -0.05f : +0.05f;
// Width larger than 0.12 slows rotation?
this.flipperBody = Box2DFactory.createWall(world, cx+ext, cy-0.12f, cx+flipperLength, cy+0.12f, 0f);
flipperBody.setType(BodyDef.BodyType.DynamicBody);
flipperBody.setBullet(true);
flipperBody.getFixtureList().get(0).setDensity(5.0f);
jointDef = new RevoluteJointDef();
jointDef.initialize(anchorBody, flipperBody, new Vector2(this.cx, this.cy));
jointDef.enableLimit = true;
jointDef.enableMotor = true;
// counterclockwise rotations are positive, so flip angles for flippers extending left
jointDef.lowerAngle = (this.flipperLength>0) ? this.minangle : -this.maxangle;
jointDef.upperAngle = (this.flipperLength>0) ? this.maxangle : -this.minangle;
jointDef.maxMotorTorque = 1000f;
this.joint = (RevoluteJoint)world.createJoint(jointDef);
flipperBodySet = Collections.singletonList(flipperBody);
this.setEffectiveMotorSpeed(-this.downspeed); // Force flipper to bottom when field is first created.
}
代码示例来源:origin: manuelbua/uracer-kotd
body.setBullet(true);
body.setUserData(this);
内容来源于网络,如有侵权,请联系作者删除!