SetMass() публичный Метод

Set the mass properties. Note that this changes the center of mass position. If you are not sure how to compute mass properties, use SetMassFromShapes. The inertia tensor is assumed to be relative to the center of mass.
public SetMass ( MassData massData ) : void
massData Box2DX.Collision.MassData The mass properties.
Результат void
Пример #1
0
        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);
        }