public class PlayerController
extends com.badlogic.gdx.InputAdapter
Modifier and Type | Field and Description |
---|---|
private boolean |
east
Booleans storing what keys have been pressed and not released
|
private boolean |
north
Booleans storing what keys have been pressed and not released
|
private Player |
player
This stores the player that the controller controls
|
private ScoreTracker |
scoreTracker |
private boolean |
south
Booleans storing what keys have been pressed and not released
|
int |
timer
This timer is used to measure how long input has been read for
|
private boolean |
west
Booleans storing what keys have been pressed and not released
|
Constructor and Description |
---|
PlayerController(Player player,
ScoreTracker scoreTracker)
Constructor to create the PlayerController to control the provided Player
|
Modifier and Type | Method and Description |
---|---|
boolean |
keyDown(int keycode)
This method is called when a key press is read
|
boolean |
keyUp(int keycode)
This method is called when a key release is read
|
void |
update()
This method is called once a game tick to transfer the key reads to the live game data in the logic Thread.
|
public int timer
private boolean north
private boolean south
private boolean west
private boolean east
private Player player
private ScoreTracker scoreTracker
public PlayerController(Player player, ScoreTracker scoreTracker)
player
- The player that we want this controller to control.scoreTracker
- The score tracker to reference.public boolean keyDown(int keycode)
keyDown
in interface com.badlogic.gdx.InputProcessor
keyDown
in class com.badlogic.gdx.InputAdapter
keycode
- - The code of the key pressedpublic boolean keyUp(int keycode)
keyUp
in interface com.badlogic.gdx.InputProcessor
keyUp
in class com.badlogic.gdx.InputAdapter
keycode
- - The keycode of the released keypublic void update()