Skip to content

Instantly share code, notes, and snippets.

@sethvincent
Created March 31, 2013 03:58
Show Gist options
  • Save sethvincent/5279493 to your computer and use it in GitHub Desktop.
Save sethvincent/5279493 to your computer and use it in GitHub Desktop.
Example of using the d-pad with libgdx. Works with Ouya. Also works with wasd keys for desktop.
if(Gdx.input.isKeyPressed(Keys.DPAD_LEFT) || Gdx.input.isKeyPressed(Keys.A)) {
player.x -= playerSpeed * Gdx.graphics.getDeltaTime();
}
if(Gdx.input.isKeyPressed(Keys.DPAD_RIGHT) || Gdx.input.isKeyPressed(Keys.D)) {
player.x += playerSpeed * Gdx.graphics.getDeltaTime();
}
if(Gdx.input.isKeyPressed(Keys.DPAD_UP) || Gdx.input.isKeyPressed(Keys.W)) {
player.y += playerSpeed * Gdx.graphics.getDeltaTime();
}
if(Gdx.input.isKeyPressed(Keys.DPAD_DOWN) || Gdx.input.isKeyPressed(Keys.S)) {
player.y -= playerSpeed * Gdx.graphics.getDeltaTime();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment