本文整理汇总了Java中com.badlogic.gdx.Input.Keys类的典型用法代码示例。如果您正苦于以下问题:Java Keys类的具体用法?Java Keys怎么用?Java Keys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Keys类属于com.badlogic.gdx.Input包,在下文中一共展示了Keys类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleInputGame
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
private void handleInputGame(float deltaTime) {
if (cameraHelper.hasTarget(level.bunnyHead)) {
// Player Movement
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
level.bunnyHead.velocity.x = -level.bunnyHead.terminalVelocity.x;
} else if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
level.bunnyHead.velocity.x = level.bunnyHead.terminalVelocity.x;
} else {
// Execute auto-forward movement on non-desktop platform
if (Gdx.app.getType() != Application.ApplicationType.Desktop) {
level.bunnyHead.velocity.x = level.bunnyHead.terminalVelocity.x;
}
}
// Bunny Jump
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.SPACE))
level.bunnyHead.setJumping(true);
else
level.bunnyHead.setJumping(false);
}
}
示例2: update
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public void update()
{
float gameTime = Gdx.graphics.getDeltaTime();
if (Gdx.input.isKeyPressed(Keys.UP)) //Forward
AddToCameraPosition(new Vector3(0, 0, -cameraSpeed * gameTime));
if (Gdx.input.isKeyPressed(Keys.DOWN)) //Backward
AddToCameraPosition(new Vector3(0, 0, cameraSpeed * gameTime));
if (Gdx.input.isKeyPressed(Keys.RIGHT)) //Right
AddToCameraPosition(new Vector3(cameraSpeed * gameTime, 0, 0));
if (Gdx.input.isKeyPressed(Keys.LEFT)) //Left
AddToCameraPosition(new Vector3(-cameraSpeed * gameTime, 0, 0));
if (Gdx.input.isKeyPressed(Keys.Q)) //Up
AddToCameraPosition(new Vector3(0, cameraSpeed * gameTime, 0));
if (Gdx.input.isKeyPressed(Keys.Z)) //Down
AddToCameraPosition(new Vector3(0, -cameraSpeed * gameTime, 0));
}
示例3: update
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public void update(float gameTime) {
super.update(gameTime);
if (Utils.isKeyDown(Keys.SPACE)) {
// create a new bird after press space key if the bird is not
// existed
if (!checkExistingBird())
createBird();
}
if (Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) {
if (!uiManager.isMenuVisible()) {
uiManager.setMenuVisible(true);
}
}
}
示例4: keycodeSelectionIf
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
private int keycodeSelectionIf(int keycode){
if (keycode == Keys.NUM_1) {
selected = 0;
}
if (keycode == Keys.NUM_2) {
selected = 1;
}
if (keycode == Keys.NUM_3) {
selected = 2;
}
if (keycode == Keys.NUM_4) {
selected = 3;
}
if (keycode == Keys.NUM_5) {
selected = 4;
}
}
示例5: keycodeSelection
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
private int keycodeSelection(int keycode) {
keycodeSelectionIf( keycode);
if (keycode == Keys.NUM_6) {
selected = 5;
}
if (keycode == Keys.NUM_7) {
selected = 6;
}
if (keycode == Keys.NUM_8) {
selected = 7;
}
if (keycode == Keys.NUM_9) {
selected = 8;
}
}
示例6: render
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
public void render(){
Gdx.gl.glClearColor(backgroundColour.r, backgroundColour.g, backgroundColour.b, backgroundColour.a);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.graphics.setTitle("Voice Chat Test by James Billy - " + Gdx.graphics.getFramesPerSecond() + "fps");
batch.begin();
font.setColor(Color.BLACK);
// Test only
if(Gdx.input.isKeyPressed(Keys.SPACE)){
// This line here is important, it will send audio when called.
this.sender.sendVoice(this.client, Gdx.graphics.getDeltaTime());
// Test only
font.draw(batch, "Now sending audio...", 10, 20);
}else{
// Test only
font.draw(batch, "Press SPACE to send audio!\n"
+ "There may be latency. This is unavoidable, sorry.", 10, 60);
}
batch.end();
}
示例7: render
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public void render () {
// Clean screen
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// creates a square at the clicked point
if(Gdx.input.justTouched()){
createBody();
}
// enable or disable debug mode
if(Gdx.input.isKeyJustPressed(Keys.D)){
water.setDebugMode(!water.isDebugMode());
}
world.step(1/60f, 6, 2);
water.update();
water.draw(camera);
debugRenderer.render(world, camera.combined);
}
示例8: keyDown
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public boolean keyDown(int keycode)
{
if(shouldAvoidInput())
return false;
ActorManipulator dialogs = userInterface.getDialogs();
if (dialogs.isMapped(keycode))
dialogs.showOrHide(keycode);
else if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_9)
spellQuickAccessAction(keycode - Keys.NUM_1);
else if (keycode >= Keys.F1 && keycode <= Keys.F12)
itemQuickAccessAction(keycode - Keys.F1);
return false;
}
示例9: createUI
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
private void createUI() {
setMovable(true);
text("Insert the Mini-Habit name:")
.button("OK", true)
.key(Keys.ENTER, true)
.button("Cancel", false)
.key(Keys.ESCAPE, false);
tfHabitName = new TextField("", getSkin());
tfHabitName.setMessageText("name");
Table contentTable = getContentTable();
contentTable.row();
contentTable.add(tfHabitName).width(135);
}
示例10: handleInput
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public void handleInput() {
// Escape to quit to exit faster. Remember to remove this later!
if (Gdx.input.isKeyPressed(Keys.ESCAPE)) {
dispose();
Gdx.app.exit();
}
// Set Game Keys
if (inputAllowed) {
player.setLeft(GameKeys.isDown(GameKeys.LEFT));
player.setRight(GameKeys.isDown(GameKeys.RIGHT));
player.setUp(GameKeys.isDown(GameKeys.UP));
player.setDown(GameKeys.isDown(GameKeys.DOWN));
player.setShoot(GameKeys.isDown(GameKeys.SPACE));
player.setMissile(GameKeys.isPressed(GameKeys.SHIFT));
}
// Update Keys
GameKeys.update();
}
示例11: config_loading_stage
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
private void config_loading_stage() {
// TODO Auto-generated method stub
loading_stage = new Stage(managment_viewport, batch);
loading_stage.addActor(logo_actor);
loading_stage.addActor(loading_background_actor);
loading_stage.addActor(loading_actor);
loading_stage.addListener(new InputListener(){
@Override
public boolean keyDown(InputEvent event, int keycode) {
// TODO Auto-generated method stub
if(keycode == Keys.BACK){
back_button_down();
}
return true;
}
});
}
示例12: keyDown
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public boolean keyDown(int keycode) {
if (functionKeys(keycode)) return true;
if (keycode == blocksMenu) {
toggleInventory();
return true;
}
int selected = -1;
if (keycode == Keys.NUM_1) selected = 0;
if (keycode == Keys.NUM_2) selected = 1;
if (keycode == Keys.NUM_3) selected = 2;
if (keycode == Keys.NUM_4) selected = 3;
if (keycode == Keys.NUM_5) selected = 4;
if (keycode == Keys.NUM_6) selected = 5;
if (keycode == Keys.NUM_7) selected = 6;
if (keycode == Keys.NUM_8) selected = 7;
if (keycode == Keys.NUM_9) selected = 8;
if (selected != -1) {
Cubes.getClient().player.getInventory().hotbarSelected = selected;
Cubes.getClient().player.getInventory().sync();
return true;
}
return false;
}
示例13: onKeyPressed
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
public void onKeyPressed(UserEvent e) {
datapointer.playerinputconvertor.onKeyPressed(e);
switch (e.value) {
case Keys.ESCAPE:
parent.parent.substate = new InGameMenuState(parent.parent);
break;
case Keys.A:
activedcapacity = (byte) ((activedcapacity == 1 || datapointer.player.inventory
.getCapFromId((byte) 1) == null) ? 0 : 1);
break;
case Keys.Z:
activedcapacity = (byte) ((activedcapacity == 2 || datapointer.player.inventory
.getCapFromId((byte) 2) == null) ? 0 : 2);
break;
case Keys.E:
activedcapacity = (byte) ((activedcapacity == 3 || datapointer.player.inventory
.getCapFromId((byte) 3) == null) ? 0 : 3);
break;
}
}
示例14: Screen
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
public Screen(ScreenManager manager) {
this.manager = manager;
adapter = new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
if (keycode == Keys.ESCAPE)
Gdx.app.exit();
keyPressed = true;
ScreenManager.multiplexer.removeProcessor(adapter);
return true;
}
};
ScreenManager.multiplexer.addProcessor(adapter);
}
示例15: keyDown
import com.badlogic.gdx.Input.Keys; //导入依赖的package包/类
@Override
public boolean keyDown(int keycode) {
if (keycode == Keys.UP) {
upPressed = true;
} else if (keycode == Keys.LEFT) {
leftPressed = true;
} else if (keycode == Keys.DOWN) {
downPressed = true;
} else if (keycode == Keys.RIGHT) {
rightPressed = true;
}
if (keycode == Keys.E) {
ePressed = true;
} else if (keycode == Keys.W) {
wPressed = true;
}
return false;
}