我使用的基本libgdx Box2D的管理游戏的物理运算。 一切工作正常,除了旋转:即使我设置
anyobject.body.setAngularVelocity(someLargeConstant);
对象真的慢(几乎以相同的速度)旋转,不管是什么“someLargeConstant”的。 除了当我使用的参数小的数字,它可以旋转速度较慢。 因此,我认为我不知有我的世界对象,应设置一些小的值内最大恒定角速度。
(我还与线速度类似的问题之前,我通过调整个像素/米的规模解决了这个问题。因此,它不太可能的问题是一个比例的问题。)
我怎样才能使物体旋转得更快?
下面是我使用的代码:
private static World world = new World(new Vector2(0, 0), true); //Create a world with no gravity
创建一个对象我调用另一个类
public Object(World world, short category, short mask, float x, float y, float radius, Sprite image,
float maxSpeed, float frictionStrength, float linearDamping, float angularDamping, boolean movable,
float elasticity, float mass){
this.world = world;
this.category = category;
this.mask = mask;
// We set our body type
this.bodyDef = new BodyDef();
if(movable==true){bodyDef.type = BodyType.DynamicBody;}else{bodyDef.type = BodyType.StaticBody;}
// Set body's starting position in the world
bodyDef.position.set(x, y);
bodyDef.linearDamping = linearDamping;
bodyDef.angularDamping = angularDamping;
// Create our body in the world using our body definition
this.body = world.createBody(bodyDef);
// Create a circle shape and set its radius
CircleShape circle = new CircleShape();
circle.setRadius(radius);
// Create a fixture definition to apply our shape to
fixtureDef = new FixtureDef();
fixtureDef.shape = circle;
fixtureDef.density = (float) (mass/(Math.PI*radius*radius));
fixtureDef.friction = frictionStrength;
fixtureDef.restitution = elasticity;
fixtureDef.filter.categoryBits = category;
fixtureDef.filter.maskBits = mask;
// Create our fixture and attach it to the body
this.fixture = body.createFixture(fixtureDef);
// BodyDef and FixtureDef don't need disposing, but shapes do.
circle.dispose();
... unrelated functions after that
}
在这里,我只是尽量使其旋转快:
tempBall.body.setAngularVelocity(20000);