所以我需要做的很简单--如何用flex4和AS3创建一个可拖放的圆,并用Box2d让它沿着拖拽的方向飞得更远,而不是停下来?
发布于 2011-06-14 17:27:38
使用LinearDamping。
这就是我如何在我的自上而下的射击中使用它来减慢对象,如果线速度停止被应用的话。
//Body is created using body definition
var b:b2Body = GameCore.environment.world.CreateBody(bodyDef);
//Fixture definition holds data such as density, friction and shape
var fixtureDef:b2FixtureDef;
fixtureDef = new b2FixtureDef();
//Define vertices etc in polygon shape
var shape:b2CircleShape;
shape = new b2CircleShape(Values.ptm(_diameter / 2));
//Assign values
fixtureDef.shape = shape;
fixtureDef.density = 1.5;
fixtureDef.friction = 0.3;
fixtureDef.restitution = 0.45;
//Add fixture to appropriate body
b.CreateFixture(fixtureDef);
//Movement Physics Settings
b.SetLinearDamping(_linearDamping);
b.SetAngularDamping(_angularDamping);发布于 2011-04-08 04:54:55
您可能希望确保关闭重力(两个维度均为零),例如
var gravity:b2Vec2 = new b2Vec2 (0.0, 0.0);然后让摩擦力减慢速度。
https://stackoverflow.com/questions/4634767
复制相似问题