所以我需要的是简单的 - 如何使用flex 4和AS3创建一个可拖放的圆圈并使用Box2d让它在拖动方向上飞得更多而不是停止?
答案 0 :(得分:3)
您可能希望确保关闭重力(两个维度都为零),例如
var gravity:b2Vec2 = new b2Vec2 (0.0, 0.0);
然后让摩擦减慢。
答案 1 :(得分:3)
使用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);