Class FirstPersonCameraController

  • All Implemented Interfaces:
    InputProcessor

    public class FirstPersonCameraController
    extends InputAdapter
    Takes a Camera instance and controls it via w,a,s,d and mouse panning.
    • Field Detail

      • camera

        protected final Camera camera
      • strafeLeftKey

        public int strafeLeftKey
      • strafeRightKey

        public int strafeRightKey
      • forwardKey

        public int forwardKey
      • backwardKey

        public int backwardKey
      • upKey

        public int upKey
      • downKey

        public int downKey
      • autoUpdate

        public boolean autoUpdate
      • velocity

        protected float velocity
      • degreesPerPixel

        protected float degreesPerPixel
    • Constructor Detail

      • FirstPersonCameraController

        public FirstPersonCameraController​(Camera camera)
    • Method Detail

      • keyDown

        public boolean keyDown​(int keycode)
        Description copied from interface: InputProcessor
        Called when a key was pressed
        Specified by:
        keyDown in interface InputProcessor
        Overrides:
        keyDown in class InputAdapter
        Parameters:
        keycode - one of the constants in Input.Keys
        Returns:
        whether the input was processed
      • keyUp

        public boolean keyUp​(int keycode)
        Description copied from interface: InputProcessor
        Called when a key was released
        Specified by:
        keyUp in interface InputProcessor
        Overrides:
        keyUp in class InputAdapter
        Parameters:
        keycode - one of the constants in Input.Keys
        Returns:
        whether the input was processed
      • setVelocity

        public void setVelocity​(float velocity)
        Sets the velocity in units per second for moving forward, backward and strafing left/right.
        Parameters:
        velocity - the velocity in units per second
      • setDegreesPerPixel

        public void setDegreesPerPixel​(float degreesPerPixel)
        Sets how many degrees to rotate per pixel the mouse moved.
        Parameters:
        degreesPerPixel -
      • touchDragged

        public boolean touchDragged​(int screenX,
                                    int screenY,
                                    int pointer)
        Description copied from interface: InputProcessor
        Called when a finger or the mouse was dragged.
        Specified by:
        touchDragged in interface InputProcessor
        Overrides:
        touchDragged in class InputAdapter
        pointer - the pointer for the event.
        Returns:
        whether the input was processed
      • update

        public void update()
      • update

        public void update​(float deltaTime)