Java Box2D:LinearImpulse的问题
我对Box2D有问题。 我尝试在render()中执行LinearImpulse: 但它不起作用。身体保持它的姿势 动态体Java Box2D:LinearImpulse的问题,java,android,libgdx,box2d,Java,Android,Libgdx,Box2d,我对Box2D有问题。 我尝试在render()中执行LinearImpulse: 但它不起作用。身体保持它的姿势 动态体 public static Body createBox(World world, BodyType type, float width, float height, float density) { BodyDef def = new BodyDef(); def.type = type; Body box = world.createBody(d
public static Body createBox(World world, BodyType type, float width, float height, float density)
{
BodyDef def = new BodyDef();
def.type = type;
Body box = world.createBody(def);
PolygonShape poly = new PolygonShape();
poly.setAsBox(width, height);
box.createFixture(poly, density);
poly.dispose();
return box;
}
body = MyWorld.createBox(world, BodyDef.BodyType.DynamicBody, WIDTH, HEIGHT, 1);
body.setTransform(startX, startY, 0);
body.setFixedRotation(true);
LinearveLocation运行良好
好的,我给冲动设定了一个很大的值,它就开始工作了。但身体只能移动约1米(与身体接触后)。我怎样才能让身体移动得更远 好的,我给冲动设定了一个很大的值,它就开始工作了。但身体只能移动约1米(与身体接触后)。我怎样才能使身体移动得更远?是否使用Box2D缩小所有尺寸?因为若你们设置宽度和高度,通常一个Box2D对象的重量会很大。因此,您可能需要相应地设置质量。或者开始使用缩小的物理。
public static Body createBox(World world, BodyType type, float width, float height, float density)
{
BodyDef def = new BodyDef();
def.type = type;
Body box = world.createBody(def);
PolygonShape poly = new PolygonShape();
poly.setAsBox(width, height);
box.createFixture(poly, density);
poly.dispose();
return box;
}
body = MyWorld.createBox(world, BodyDef.BodyType.DynamicBody, WIDTH, HEIGHT, 1);
body.setTransform(startX, startY, 0);
body.setFixedRotation(true);