예제 #1
0
        public override void Update(GameTime gt)
        {
            if (!HasFocus && (MouseService.Delta != Point.Zero || MouseService.IsMouseButtonDown(MouseButton.LeftButton)))
            {
                GetFocus(this);
            }
            if (HasFocus)
            {
                Position = new Vector2(Position.X - MouseService.Delta.X, Position.Y - MouseService.Delta.Y);

                //Move it with the camera.
                Position += EntityGame.ActiveCamera.Delta;

                //Keep it from leaving the bounds of the window.
                if (Body.Position.X < EntityGame.ActiveCamera.ScreenSpace.Left)
                {
                    Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Left;
                }
                else if (Body.BoundingRect.Right > EntityGame.ActiveCamera.ScreenSpace.Right)
                {
                    Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Right - Body.Bounds.X;
                }

                if (Body.Position.Y < EntityGame.ActiveCamera.ScreenSpace.Top)
                {
                    Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Top;
                }
                else if (Body.BoundingRect.Bottom > EntityGame.ActiveCamera.ScreenSpace.Bottom)
                {
                    Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Bottom - Body.Bounds.Y;
                }
            }

            base.Update(gt);
        }
예제 #2
0
 public override bool Down()
 {
     return(MouseService.IsMouseButtonDown(Button));
 }