本文整理汇总了C#中Box2DX.Dynamics.Body.SetMass方法的典型用法代码示例。如果您正苦于以下问题:C# Body.SetMass方法的具体用法?C# Body.SetMass怎么用?C# Body.SetMass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2DX.Dynamics.Body
的用法示例。
在下文中一共展示了Body.SetMass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitPhysics
private void InitPhysics(BattleArena arena)
{
// Define the dynamic body. We set its position and call the body factory.
BodyDef bodyDef = new BodyDef();
bodyDef.Position.Set(0.0f, 4.0f);
body = arena.world.CreateBody(bodyDef);
// Define another box shape for our dynamic body.
PolygonDef shapeDef = new PolygonDef();
shapeDef.SetAsBox(Pokemon.Width / 2, Pokemon.Height / 2);
// Set the box density to be non-zero, so it will be dynamic.
shapeDef.Density = 1.0f;
// Override the default friction.
//shapeDef.Friction = 2f;
// Add the shape to the body.
Fixture fix = body.CreateFixture(shapeDef);
fix.Density = 1;
fix.Friction = 0.3f;
fix.Restitution = 0.1f;
fix.UserData = this;
fix.Filter.GroupIndex = this.ID;
fix.Filter.CategoryBits = 0x0002;
if (Pokemon.Types.Contains(PokemonType.Ghost)){
fix.Filter.MaskBits = 0xFFFF - 0x0002;
} else {
fix.Filter.MaskBits = 0xFFFF;
}
// Now tell the dynamic body to compute it's mass properties base
// on its shape.
var mass = body.GetMassData();
mass.Mass = Pokemon.Weight;
body.SetMass(mass);
body.SetFixedRotation(true);
}