com.badlogic.gdx.Input Java Examples
The following examples show how to use
com.badlogic.gdx.Input.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HudRenderer.java From xibalba with MIT License | 6 votes |
private void setupDeathDialog() { deathDialog = new Dialog("", Main.skin) { public void result(Object obj) { if (obj.equals(true)) { Main.playScreen.dispose(); main.setScreen(new MainMenuScreen(main)); } else { Gdx.app.exit(); } } }; deathDialog.button("[DARK_GRAY][[[CYAN] ENTER [DARK_GRAY]][WHITE] Return to Main Menu", true); deathDialog.key(Input.Keys.ENTER, true); deathDialog.button("[DARK_GRAY][[[CYAN] Q [DARK_GRAY]][WHITE] Quit", false); deathDialog.key(Input.Keys.Q, false); deathDialog.pad(10); }
Example #2
Source File: RetroSceneScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public boolean keyUp(int keycode) { switch (keycode) { case Input.Keys.ESCAPE: case Input.Keys.BACK: case Input.Keys.MENU: ui.setCurrentScreen(Screens.MENU_SCREEN); break; case Input.Keys.SPACE: if (drawHotspots) drawHotspots = false; break; } return true; }
Example #3
Source File: WndKeymap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
private void reconfigureKeysText() { if (keys.key1 > 0) { key1.text( Input.Keys.toString( keys.key1 ) ); key1.hardlight( BOUND ); } else { key1.text( TXT_UNASSIGNED ); key1.hardlight( NOT_BOUND ); } //key1.measure(); if (keys.key2 > 0) { key2.text( Input.Keys.toString( keys.key2 ) ); key2.hardlight( BOUND ); } else { key2.text( TXT_UNASSIGNED ); key2.hardlight( NOT_BOUND ); } //key2.measure(); layout(); }
Example #4
Source File: Raycaster.java From raycaster with MIT License | 6 votes |
@Override public void render () { if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { Gdx.app.exit(); } Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); orthoCamera.update(); Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height); seconds = Gdx.graphics.getDeltaTime(); map.update(seconds); controls.update(); player.update(controls, map, seconds); camera.render(player, map); }
Example #5
Source File: SimpleRoom.java From gdx-vr with Apache License 2.0 | 6 votes |
@Override public void render() { float deltaTime = Gdx.graphics.getDeltaTime(); if (Gdx.input.isKeyPressed(Input.Keys.W)) { VirtualReality.body.position.add(new Vector3(0, 0, -2).mul(VirtualReality.body.orientation).scl(deltaTime)); } if (Gdx.input.isKeyPressed(Input.Keys.S)) { VirtualReality.body.position.add(new Vector3(0, 0, 2).mul(VirtualReality.body.orientation).scl(deltaTime)); } if (Gdx.input.isKeyPressed(Input.Keys.A)) { VirtualReality.body.orientation.mulLeft(new Quaternion(Vector3.Y, 90f * deltaTime)); } if (Gdx.input.isKeyPressed(Input.Keys.D)) { VirtualReality.body.orientation.mulLeft(new Quaternion(Vector3.Y, -90f * deltaTime)); } VirtualReality.update(Gdx.graphics.getDeltaTime()); VirtualReality.renderer.render(); }
Example #6
Source File: OverlayGame.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
@Override /** * creates OverlayGame and sets Screen */ public void create () { // Give an int, n, to Sprites if you want an nxn matrix this.sprites = new Sprites(); this.cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); this.renderer = new Renderer(cam, sprites); InputReplacer ir = new InputReplacer(); // Create instance of input proxy ir.setProxiedInput(Gdx.input); // Give InputProxy current Gdx.input Gdx.input = ir; // Replace Gdx.input with input proxy // Connect server keys with the keys that would be normally pressed // Add all keys that are needed and give them a different server key: ControlModeFacade.commandsBuffer.addKeyCommand(1, Input.Keys.LEFT); ControlModeFacade.commandsBuffer.addKeyCommand(0, Input.Keys.UP); ControlModeFacade.commandsBuffer.addKeyCommand(2, Input.Keys.DOWN); ControlModeFacade.commandsBuffer.addKeyCommand(3, Input.Keys.RIGHT); // Set screen to ExampleUseCase Menu setScreen(new MainMenuScreen(this)); }
Example #7
Source File: InputProxy.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Goes down the hierarchy of InputProxies, starting at Gdx.input and * removes the given InputProxy, if it exists. Returns if the given * {@link InputProxy} was found and removed. * * @param proxy the proxy to be found and removed * @return true if the specified proxy was removed, false otherwise */ public static boolean removeProxyFromGdx(InputProxy proxy) { if (Gdx.input == null) { return false; } if (Gdx.input.equals(proxy)) { synchronized (Gdx.input) { Gdx.input = proxy.getProxiedInput(); } return true; } Input current = Gdx.input; InputProxy asProxy; while (current != null && current instanceof InputProxy) { asProxy = (InputProxy) current; if (asProxy.getProxiedInput() == proxy) { asProxy.setProxiedInput(proxy.getProxiedInput()); return true; } current = asProxy.getProxiedInput(); } return false; }
Example #8
Source File: EventUtils.java From riiablo with Apache License 2.0 | 6 votes |
public static boolean click(Button button) { if (button.isDisabled()) return false; InputEvent event = Pools.obtain(InputEvent.class); event.setType(InputEvent.Type.touchDown); event.setStage(button.getStage()); event.setStageX(0); event.setStageY(0); event.setPointer(0); event.setButton(Input.Buttons.LEFT); event.setListenerActor(button); button.fire(event); event.setType(InputEvent.Type.touchUp); button.fire(event); Pools.free(event); return true; }
Example #9
Source File: ShortcutParser.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
private static HashMap<String, Integer> prepareKeyCodes() { HashMap<String, Integer> keyCodes = new HashMap<>(); Field[] fields = Input.Keys.class.getDeclaredFields(); for (Field field : fields) { int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers) && field.getType()==Integer.TYPE) { try { int code = field.getInt(null); String name = field.getName(); keyCodes.put(name, code); } catch (IllegalAccessException ignore) { } } } return keyCodes; }
Example #10
Source File: MainMenuScreen.java From xibalba with MIT License | 6 votes |
/** * Main Menu Screen. * * @param main Instance of main class */ public MainMenuScreen(Main main) { stage = new Stage(new FitViewport(960, 540)); Table table = new Table(); table.setFillParent(true); stage.addActor(table); ActionButton newGameButton = new ActionButton("N", "New Game"); newGameButton.setKeys(Input.Keys.N); newGameButton.setAction(table, () -> main.setScreen(new YouScreen(main))); ActionButton quitButton = new ActionButton("Q", "Quit"); quitButton.setKeys(Input.Keys.Q); quitButton.setAction(table, () -> Gdx.app.exit()); table.add(new Label("[LIGHT_GRAY]Xibalba v0.1.0[]", Main.skin)).pad(0, 0, 10, 0); table.row(); table.add(newGameButton).pad(0, 0, 10, 0); table.row(); table.add(quitButton); Gdx.input.setInputProcessor(stage); stage.setKeyboardFocus(table); }
Example #11
Source File: DialogSceneComposer.java From skin-composer with MIT License | 6 votes |
public DialogSceneComposer() { super("", Main.main.getSkin(), "scene"); dialog = this; main = Main.main; skin = main.getSkin(); graphDrawer = main.getGraphDrawer(); events = new DialogSceneComposerEvents(); model = new DialogSceneComposerModel(); view = View.EDIT; simActor = rootActor; setFillParent(true); populate(); addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Input.Keys.F5) { populate(); } return super.keyDown(event, keycode); } }); }
Example #12
Source File: DialogFactory.java From skin-composer with MIT License | 6 votes |
public void showDeleteStyleDialog(Skin skin, Stage stage) { StyleData styleData = main.getRootTable().getSelectedStyle(); Dialog dialog = new Dialog("Delete Style", skin, "bg") { @Override protected void result(Object object) { if ((Boolean) object) { main.getUndoableManager().addUndoable(new DeleteStyleUndoable(styleData, main), true); } } }; dialog.getTitleLabel().setAlignment(Align.center); dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f); dialog.text("Are you sure you want to delete style " + styleData.name + "?"); dialog.getContentTable().getCells().first().pad(10.0f); dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f); dialog.button("Yes, delete the style", true).button("No", false); dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.key(Input.Keys.ENTER, true).key(Input.Keys.ESCAPE, false); dialog.show(stage); }
Example #13
Source File: RenderHealthBar.java From StSLib with MIT License | 6 votes |
@SpireInsertPatch( locator=Locator.class, localvars={"x", "y"} ) public static void Insert(AbstractCreature __instance, SpriteBatch sb, float x, float y) { if (HEALTH_BAR_HEIGHT == -1) { HEALTH_BAR_HEIGHT = 20.0f * Settings.scale; HEALTH_BAR_OFFSET_Y = -28.0f * Settings.scale; } if (!Gdx.input.isKeyPressed(Input.Keys.H)) { if (TempHPField.tempHp.get(__instance) > 0 && __instance.hbAlpha > 0) { renderTempHPIconAndValue(__instance, sb, x, y); } } }
Example #14
Source File: PlayScreen.java From Bomberman_libGdx with MIT License | 6 votes |
public void handleInput() { if (Gdx.input.isKeyJustPressed(Input.Keys.B)) { showB2DDebugRenderer = !showB2DDebugRenderer; } if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { paused = !paused; if (paused) { GameManager.getInstance().playSound("Pause.ogg"); GameManager.getInstance().pauseMusic(); } else { GameManager.getInstance().playMusic(); } } }
Example #15
Source File: ModuleBoardWidget.java From talos with Apache License 2.0 | 6 votes |
public void wrapperClicked(ModuleWrapper wrapper) { wasWrapperDragged = null; if(selectedWrappers.contains(wrapper)) { wasWrapperSelectedOnDown = wrapper; } else { wasWrapperSelectedOnDown = null; } if(Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) { addWrapperToSelection(wrapper); } else { if(!selectedWrappers.contains(wrapper)) { selectWrapper(wrapper); } } }
Example #16
Source File: Splash.java From Skyland with MIT License | 6 votes |
@Override public void render(float v) { Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Skyland.getInstance().renderStage(); if (Gdx.input.isKeyPressed(Input.Keys.BACK)) System.exit(0); if (!loaded && Assets.update()) loaded = true; if (loaded && animationFinished) { Assets.addSkinRegions("skins/skin.pack"); addFonts(); Assets.menuSkin.load(Gdx.files.internal("skins/skin.json")); Skyland.getInstance().setScreen(new MenuScene()); } }
Example #17
Source File: ChestBlock.java From TerraLegion with MIT License | 6 votes |
/** * @return Whether the chest is being tapped */ public boolean isTapped(OrthographicCamera camera, float blockX, float blockY){ this.mousePosition.set(Gdx.input.getX(), Gdx.input.getY(), 0); this.mousePosition = camera.unproject(mousePosition); if(this.mouseBounds == null){ this.mouseBounds = new Rectangle(mousePosition.x, mousePosition.y, 0, 0); } this.mouseBounds.set(this.mousePosition.x, this.mousePosition.y, 0, 0); if(this.getBody(blockX, blockY).getBounds().overlaps(mouseBounds) && Gdx.input.isButtonPressed(Input.Buttons.LEFT)){ return true; } return false; }
Example #18
Source File: World.java From TerraLegion with MIT License | 5 votes |
public void update(OrthoCamera camera) { chunkManager.updateChunks(physicsWorld, player.getX(), player.getY()); physicsWorld.updateWorldBody(player); physicsWorld.focusCamera(player, Settings.getWidth(), Settings.getHeight(), 50000, 50000, camera); chunkManager.updateChunks(physicsWorld, player.getX(), player.getY()); if (Gdx.input.isKeyJustPressed(Input.Keys.J)) { Chunk chunk1 = chunkManager.getChunkFromPos(player.getX(), player.getY()); bunny = new Bunny(player.getX(), player.getY()); chunk1.addEntity(bunny); physicsWorld.setGravityToEntity(bunny); } DayManager.getInstance().update(); }
Example #19
Source File: DayManager.java From TerraLegion with MIT License | 5 votes |
public void update() { if (Gdx.input.isKeyJustPressed(Input.Keys.O)) { worldLightValue += 0.05f; if (worldLightValue > 1) worldLightValue = 1; } else if (Gdx.input.isKeyPressed(Input.Keys.L)) { worldLightValue -= 0.05f; if (worldLightValue < 0) worldLightValue = 0; } }
Example #20
Source File: Hero.java From JavaExercises with GNU General Public License v2.0 | 5 votes |
public void update() { if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) { position.y -= speed; if (position.y < 0) position.y = 0; } if (Gdx.input.isKeyPressed(Input.Keys.UP)) { position.y += speed; if (position.y > Gdx.graphics.getHeight() - imgShip.getHeight()) position.y = Gdx.graphics.getHeight() - imgShip.getHeight(); } if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { position.x += speed; if (position.x > Gdx.graphics.getWidth() - imgShip.getWidth()) position.x = Gdx.graphics.getWidth() - imgShip.getWidth(); } if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { position.x -= speed; if (position.x < 0) position.x = 0; } if (Gdx.input.isKeyPressed(Input.Keys.SPACE) || Gdx.input.isTouched()) { fireCounter++; if (fireCounter > 8) { // control of the rate of fire fireCounter = 0; fire(); } } }
Example #21
Source File: RenderedConsole.java From riiablo with Apache License 2.0 | 5 votes |
@Override public boolean keyTyped(char ch) { if (!visible) return false; if (Keys.Console.isAssigned(Input.Keys.valueOf(Character.toString(ch)))) { return true; } super.keyTyped(ch); return true; }
Example #22
Source File: RestrictMenuButton.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void start(Callback callback) { Stage stage = resources.get("stage"); InputListener listener = new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { if (keycode == Input.Keys.MENU) { event.cancel(); return true; } return super.keyDown(event, keycode); } }; stage.addCaptureListener(listener); resources.put("restrictMenuButton", listener); callback.taskEnded(); }
Example #23
Source File: State.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public boolean keyUp(InputEvent event, int keycode) { if (keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) { if (!WindowManager.instance.handleBackPressed()) { onBackPressed(); } } else if (keycode == Input.Keys.MENU) { onMenuPressed(); } return super.keyUp(event, keycode); }
Example #24
Source File: DialogFactory.java From skin-composer with MIT License | 5 votes |
public Dialog yesNoDialog(String title, String text, ConfirmationListener listener, DialogListener dialogListener) { Dialog dialog = new Dialog(title, main.getSkin(), "bg") { @Override public Dialog show(Stage stage, Action action) { fire(new DialogEvent(DialogEvent.Type.OPEN)); return super.show(stage, action); } @Override protected void result(Object object) { listener.selected((int) object); fire(new DialogEvent(DialogEvent.Type.CLOSE)); } }; if (dialogListener != null) { dialog.addListener(dialogListener); } dialog.getTitleTable().getCells().first().padLeft(5.0f); Label label = new Label(text, main.getSkin()); label.setAlignment(Align.center); dialog.text(label); dialog.getContentTable().getCells().first().pad(10.0f); dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f); dialog.button("Yes", 0); dialog.button("No", 1); dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.key(Input.Keys.ESCAPE, 1); dialog.key(Keys.ENTER, 0); dialog.key(Keys.SPACE, 0); dialog.show(main.getStage()); return dialog; }
Example #25
Source File: PDInputProcessor.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected GameAction keycodeToGameAction(int keycode) { switch (keycode) { case Input.Keys.BACK: case Input.Keys.ESCAPE: return GameAction.BACK; } return null; }
Example #26
Source File: MainMenuScreen.java From SIFTrain with MIT License | 5 votes |
@Override public boolean keyUp(int keycode) { if (keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) { // do nothing return true; } return false; }
Example #27
Source File: VelocityModeChanger.java From riiablo with Apache License 2.0 | 5 votes |
@Override protected void begin() { Vector2 velocity = mVelocity.get(Riiablo.game.player).velocity; if (velocity.isZero()) return; if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) { mRunning.remove(Riiablo.game.player); velocity.setLength(6); } else { mRunning.create(Riiablo.game.player); velocity.setLength(9); } }
Example #28
Source File: GDXMouse.java From INFDEV02-4 with MIT License | 5 votes |
public IOption<Point> click() { if(Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { return new Some<Point>(new Point( (float)Gdx.input.getX(), (float)Gdx.input.getY())); } else { return new None<Point>(); } }
Example #29
Source File: GDXMouse.java From INFDEV02-4 with MIT License | 5 votes |
public IOption<Point> click() { if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { return new Some<Point>(new Point( (float) Gdx.input.getX(), (float) Gdx.input.getY())); } else { return new None<Point>(); } }
Example #30
Source File: GDXMouse.java From INFDEV02-4 with MIT License | 5 votes |
public IOption<Point> click() { if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { return new Some<Point>(new Point( (float) Gdx.input.getX(), (float) Gdx.input.getY())); } else { return new None<Point>(); } }