Exemple #1
0
        public void Update()
        {
            _prevKey   = _curKey;
            _prevMouse = _curMouse;
            _curKey    = Keyboard.GetState();
            _curMouse  = Mouse.GetState();

            PrevMousePos  = MousePos;
            MousePos      = _curMouse.Position;
            MouseDeltaPos = MousePos - PrevMousePos;

            var camTransform = Components.Camera.main.CreateTransform();

            CamRelativePrevMousePos  = CamRelativeMousePos;
            CamRelativeMousePos      = Vector2.Transform(MousePos.ToVector2(), Matrix.Invert(camTransform));
            CamRelativeMouseDeltaPos = CamRelativeMousePos - CamRelativePrevMousePos;
        }
Exemple #2
0
        public static void StartFrame()
        {
            lastKeyState    = currentKeyState;
            currentKeyState = Keyboard.GetState();

            lastMouseState    = currentMouseState;
            currentMouseState = Mouse.GetState();

            MousePos      = currentMouseState.Position;
            MouseWorldPos = Main.Camera.ScreenToWorldPosition(MousePos.ToVector2());
            MouseInWindow = Screen.Contains(MousePos.X, MousePos.Y);

            MouseScrollDelta = currentMouseState.ScrollWheelValue - MouseScroll;
            MouseScroll      = currentMouseState.ScrollWheelValue;

            tileUnderMouse = GetTileFromWorldPosition(MouseWorldPos);
        }
Exemple #3
0
        public static void StartFrame()
        {
            LastKeyState    = CurrentKeyState;
            CurrentKeyState = Keyboard.GetState();

            LastMouseState    = CurrentMouseState;
            CurrentMouseState = Mouse.GetState();

            MousePos        = CurrentMouseState.Position;
            MouseWorldPos   = JEngine.Camera.ScreenToWorldPosition(MousePos.ToVector2());
            IsMouseInWindow = Screen.Contains((int)MousePos.X, (int)MousePos.Y);
            if (JEngine.TileMap != null)
            {
                MouseWorldTilePos = JEngine.TileMap.PixelToTileCoords((int)MouseWorldPos.X, (int)MouseWorldPos.Y);
            }

            MouseScrollDelta = CurrentMouseState.ScrollWheelValue - MouseScroll;
            MouseScroll      = CurrentMouseState.ScrollWheelValue;
        }