我正在尝试对我创建的身体施加力。但我似乎无法做到这一点。这是我正在创建的身体:
//create some objects
var fixDef2 = new b2FixtureDef;
fixDef2.density = 1.0;
fixDef2.friction = 0.5;
fixDef2.restitution = 0.2;
var bodyDef2 = new b2BodyDef;
bodyDef2.type = b2Body.b2_dynamicBody;
fixDef2.shape = new b2PolygonShape;
fixDef2.shape.SetAsBox(
50/30 + 0.1 //half width
, 6/30 + 0.1 //half height
);
bodyDef2.position.x = Math.random() * 10;
bodyDef2.position.y = Math.random() * 10;
bodyDef2.fixedRotation = true;
var body=world.CreateBody(bodyDef2);
body.CreateFixture(fixDef2);
我想施加一个力使身体向左移动。目前我正在尝试这个:
body.ApplyForce( direction , body.GetPosition() );
这没有做任何事情。我究竟做错了什么?