Ejemplo n.º 1
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            if (Input.MousePress(MouseButton.Left))
            {
                var     x   = Mouse.GetCursorState().X - X;
                var     y   = Mouse.GetCursorState().Y - Y;
                Vector2 pos = new Vector2(x, y) - new Vector2(Width, Height) / 2f;
                pos = view.ToWorld(pos);
                view.SetPosition(pos, TweenType.Linear, 15);
            }
            if (Input.KeyPress(Key.Up))
            {
                view.SetPosition(view.PositionGoTo + new Vector2(0, -20), TweenType.Linear, 15);
            }
            if (Input.KeyPress(Key.Down))
            {
                view.SetPosition(view.PositionGoTo + new Vector2(0, 20), TweenType.Linear, 15);
            }
            if (Input.KeyPress(Key.Left))
            {
                view.SetPosition(view.PositionGoTo + new Vector2(-20, 0), TweenType.Linear, 15);
            }
            if (Input.KeyPress(Key.Right))
            {
                view.SetPosition(view.PositionGoTo + new Vector2(20, 0), TweenType.Linear, 15);
            }

            view.Update();
            Input.Update();
        }