如果想要在应用新的力量之前删除旧的力量,可以调用clearForces方法。示例代码:
// 创建一个动力学刚体
var bodyDef = new b2BodyDef();
bodyDef.type = b2BodyType.b2_dynamicBody;
var body = world.CreateBody(bodyDef);
// 应用力量
var force = new b2Vec2(10, 0);
var point = new b2Vec2(0, 0);
body.ApplyForce(force, point);
console.log(body.GetLinearVelocity()); // 输出 (10,0)
// 再次应用力量
var force = new b2Vec2(0, 10);
var point = new b2Vec2(0, 0);
body.ApplyForce(force, point);
console.log(body.GetLinearVelocity()); // 输出 (10,10)
// 清除所有力量
body.ClearForces();
// 再次应用力量
var force = new b2Vec2(5, 5);
var point = new b2Vec2(0, 0);
body.ApplyForce(force, point);
console.log(body.GetLinearVelocity()); // 输出 (5,5)
上一篇:ApplyHingeLoss&Low-RankPositiveslosswithGraphNeuralNetworkforRecommendationSystem
下一篇:Applyingaconditionalformattingmacrotoatableincurrentsheetinsteadofanamedtable