Class InputComponent

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.input.InputComponent
All Implemented Interfaces:
GestureDetector.GestureListener, InputProcessor
Direct Known Subclasses:
InputDecorator, KeyboardPlayerInputComponent, KeyboardTerminalInputComponent, TouchPlayerInputComponent, TouchTerminalInputComponent

public abstract class InputComponent
extends Component
implements InputProcessor, GestureDetector.GestureListener
An InputComponent that supports keyboard and touch input and touch gestures. By default an InputComponent does not handle any input events.

Subclasses of InputComponent should override relevant methods to handle input. Ensure the priority is set in the subclass' constructor.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected int priority
    The priority that the input handler is visited in by InputService.

    Fields inherited from class com.deco2800.game.components.Component

    enabled, entity
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected InputComponent()
    Sets priority to the default value;
    protected InputComponent​(int priority)
    Sets input handler priority to a given value.
  • Method Summary

    Modifier and Type Method Description
    void create()
    Called when the entity is created and registered.
    void dispose()
    Called when the component is disposed.
    boolean fling​(float velocityX, float velocityY, int button)  
    int getPriority()  
    boolean keyDown​(int keycode)  
    boolean keyTyped​(char character)  
    boolean keyUp​(int keycode)  
    boolean longPress​(float x, float y)  
    boolean mouseMoved​(int screenX, int screenY)  
    boolean pan​(float x, float y, float deltaX, float deltaY)  
    boolean panStop​(float x, float y, int pointer, int button)  
    boolean pinch​(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2)  
    void pinchStop()  
    boolean pinchStopHandled()
    Wrapper for pinch stop that can be overridden.
    boolean scrolled​(float amountX, float amountY)  
    void setPriority​(int priority)  
    boolean tap​(float x, float y, int count, int button)  
    boolean touchDown​(float x, float y, int pointer, int button)  
    boolean touchDown​(int screenX, int screenY, int pointer, int button)  
    boolean touchDragged​(int screenX, int screenY, int pointer)  
    boolean touchUp​(int screenX, int screenY, int pointer, int button)  
    boolean zoom​(float initialDistance, float distance)  

    Methods inherited from class com.deco2800.game.components.Component

    earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait