Exemple #1
0
        public Player(GameHandler game, Vector3 location, Vector3 rotation, double lifeTime) : base(game, location, rotation, lifeTime)
        {
            physicsBody    = new Engine.Components.Physics.PhysicsBodyComponent(game, new Vector2(0, 0), true, this);
            shapeComponent = Engine.Components.Physics.ShapeComponent.CreateRectangeShape(game, this, false, 1.0f, 0.0f, 16.0f, 16.0f);

            Components.Add(physicsBody);

            Components.Add(shapeComponent);
        }
        public static ShapeComponent CreateRectangeShape(GameHandler game, Actor owner, bool isSensor, float density, float friction, float halfX, float halfY, string Name = "RectangeShape")
        {
            ShapeComponent component = new ShapeComponent(game, Name, owner);

            component.shapeDef          = new Box2DX.Collision.PolygonDef();
            component.shapeDef.Type     = Box2DX.Collision.ShapeType.PolygonShape;
            component.shapeDef.Density  = density;
            component.shapeDef.Friction = friction;
            component.shapeDef.IsSensor = isSensor;
            component.shapeDef.UserData = owner;

            (component.shapeDef as Box2DX.Collision.PolygonDef).SetAsBox(halfX / game.physicsScaleX, halfY / game.physicsScaleY);

            return(component);
        }