Created
March 31, 2013 03:58
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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