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: 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 #2
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 #3
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 #4
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 #5
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 #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: 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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
Source File: DemoScreen.java From gdx-vfx with Apache License 2.0 | 5 votes |
@Override public boolean keyDown(InputEvent event, int keycode) { switch (keycode) { case Input.Keys.F1: { stage.setDebugAll(stageDebug = !stageDebug); return true; } default: return super.keyDown(event, keycode); } }
Example #19
Source File: UI.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public UI(World w) { this.w = w; recorder = new Recorder(w); testerBot = new TesterBot(w); batch = new SpriteBatch(); screens = new BladeScreen[Screens.values().length]; Gdx.input.setCatchKey(Input.Keys.MENU, true); Gdx.input.setCatchKey(Input.Keys.BACK, true); loadAssets(); screens[Screens.INIT_SCREEN.ordinal()] = getCustomScreenInstance(Screens.INIT_SCREEN.toString(), InitScreen.class); screens[Screens.SCENE_SCREEN.ordinal()] = getCustomScreenInstance(Screens.SCENE_SCREEN.toString(), DefaultSceneScreen.class); screens[Screens.LOADING_SCREEN.ordinal()] = getCustomScreenInstance(Screens.LOADING_SCREEN.toString(), LoadingScreen.class); screens[Screens.MENU_SCREEN.ordinal()] = getCustomScreenInstance(Screens.MENU_SCREEN.toString(), MenuScreen.class); screens[Screens.HELP_SCREEN.ordinal()] = getCustomScreenInstance(Screens.HELP_SCREEN.toString(), HelpScreen.class); screens[Screens.CREDIT_SCREEN.ordinal()] = getCustomScreenInstance(Screens.CREDIT_SCREEN.toString(), CreditsScreen.class); screens[Screens.LOAD_GAME_SCREEN.ordinal()] = getCustomScreenInstance(Screens.LOAD_GAME_SCREEN.toString(), LoadSaveScreen.class); screens[Screens.SAVE_GAME_SCREEN.ordinal()] = getCustomScreenInstance(Screens.SAVE_GAME_SCREEN.toString(), LoadSaveScreen.class); for (BladeScreen s : screens) s.setUI(this); setCurrentScreen(Screens.INIT_SCREEN); }
Example #20
Source File: PreviewWidget.java From talos with Apache License 2.0 | 5 votes |
@Override public void act(float delta) { super.act(delta); //stupid hack, plz do it normal way if(PreviewWidget.this.hasScrollFocus() && Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { resetCamera(); } long timeBefore = TimeUtils.nanoTime(); final ParticleEffectInstance particleEffect = TalosMain.Instance().TalosProject().getParticleEffect(); particleEffect.update(Gdx.graphics.getDeltaTime()); cpuTime.put( TimeUtils.timeSinceNanos(timeBefore)); stringBuilder.clear(); stringBuilder.append(countStr).append(particleEffect.getParticleCount()); countLbl.setText(stringBuilder.toString()); stringBuilder.clear(); stringBuilder.append(trisCountStr).append(trisCount); trisCountLbl.setText(stringBuilder.toString()); stringBuilder.clear(); stringBuilder.append(nodeCallsStr).append(particleEffect.getNodeCalls()); nodeCallsLbl.setText(stringBuilder.toString()); float rt = renderTime.value/1000000f; float cp = cpuTime.value/1000000f; rt = (float)Math.round(rt * 10000f) / 10000f; cp = (float)Math.round(cp * 10000f) / 10000f; stringBuilder.clear(); stringBuilder.append(gpuTimeStr).append(rt).append(msStr); gpuTimeLbl.setText(stringBuilder.toString()); stringBuilder.clear(); stringBuilder.append(cpuTimeStr).append(cp).append(msStr); cpuTimeLbl.setText(stringBuilder.toString()); }
Example #21
Source File: StickyKeyModeImpl.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * The reset in StickyMode is responsible for: * 1) Making sure to keep some delay in between two commands such that GDX system registers it as * command. * 2) If no new command is registered, Set last command as current command after a pre-defined delay. * */ @Override public void reset() { startLastCommandWatchDog(); setGdxCommand(Input.Keys.UNKNOWN); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); if (!newCommandRegistered) executor.schedule(() -> setGdxCommand(lastGdxCommand), StandardizedInterface.KEY_REPLACER_TIME_TO_WAIT_BETWEEN_TWO_COMMANDS, TimeUnit.MILLISECONDS); }
Example #22
Source File: GdxKeyMapper.java From riiablo with Apache License 2.0 | 5 votes |
@Override public void onUnassigned(MappedKey key, int assignment, int keycode) { super.onUnassigned(key, assignment, keycode); if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) { Gdx.app.debug(TAG, String.format("unassigned [%s] from [%s]", Input.Keys.toString(keycode), key.getAlias())); } }
Example #23
Source File: FluidSimulatorGeneric.java From fluid-simulator-v2 with Apache License 2.0 | 5 votes |
@Override public boolean keyDown(int keycode) { if (keycode == Input.Keys.CONTROL_LEFT) { isDragging = true; } return false; }
Example #24
Source File: PauseScreen.java From xibalba with MIT License | 5 votes |
/** * Main Menu Screen. * * @param main Instance of main class */ public PauseScreen(Main main) { stage = new Stage(new FitViewport(960, 540)); Table table = new Table(); table.setFillParent(true); stage.addActor(table); ActionButton returnToGameButton = new ActionButton("ESC", "Return to Game"); returnToGameButton.setKeys(Input.Keys.ESCAPE); returnToGameButton.setAction(table, () -> main.setScreen(Main.playScreen)); ActionButton mainMenuButton = new ActionButton("M", "Main Menu"); mainMenuButton.setKeys(Input.Keys.M); mainMenuButton.setAction(table, () -> { Main.playScreen.dispose(); main.setScreen(new MainMenuScreen(main)); }); ActionButton quitButton = new ActionButton("Q", "Quit"); quitButton.setKeys(Input.Keys.Q); quitButton.setAction(table, () -> Gdx.app.exit()); table.add(new Label("[LIGHT_GRAY]PAUSED[]", Main.skin)).pad(0, 0, 10, 0); table.row(); table.add(returnToGameButton).pad(0, 0, 10, 0); table.row(); table.add(mainMenuButton).pad(0, 0, 10, 0); table.row(); table.add(quitButton); Gdx.input.setInputProcessor(stage); stage.setKeyboardFocus(table); }
Example #25
Source File: PauseMenuStage.java From Klooni1010 with GNU General Public License v3.0 | 5 votes |
@Override public boolean keyUp(int keyCode) { if (keyCode == Input.Keys.P || keyCode == Input.Keys.BACK) // Pause hide(); return super.keyUp(keyCode); }
Example #26
Source File: MainMenuScreen.java From Klooni1010 with GNU General Public License v3.0 | 5 votes |
@Override public void render(float delta) { Klooni.theme.glClearBackground(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta)); stage.draw(); if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) { Gdx.app.exit(); } }
Example #27
Source File: CustomizeScreen.java From Klooni1010 with GNU General Public License v3.0 | 5 votes |
@Override public void render(float delta) { Klooni.theme.glClearBackground(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), MIN_DELTA)); stage.draw(); // After everything is drawn, showcase the current shop item SnapshotArray<Actor> children = shopGroup.getChildren(); if (children.size > 0) { final ShopCard card = (ShopCard) children.get(showcaseIndex); final Batch batch = stage.getBatch(); batch.begin(); // For some really strange reason, we need to displace the particle effect // by "buyBand.height", or it will render exactly that height below where // it should. // TODO Fix this - maybe use the same project matrix as stage.draw()? // batch.setProjectionMatrix(stage.getViewport().getCamera().combined) if (!card.showcase(batch, buyBand.getHeight())) { showcaseIndex = (showcaseIndex + 1) % children.size; } batch.end(); } if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) { goBack(); } }
Example #28
Source File: GameScreen.java From Klooni1010 with GNU General Public License v3.0 | 5 votes |
@Override public boolean keyUp(int keycode) { if (keycode == Input.Keys.P || keycode == Input.Keys.BACK) // Pause showPauseMenu(); return false; }
Example #29
Source File: ControllerMenuStage.java From gdx-controllerutils with Apache License 2.0 | 5 votes |
/** * returns true if the given keyCode is a DefaultAction key/button. You can override this. */ public boolean isDefaultActionKeyCode(int keyCode) { switch (keyCode) { case Input.Keys.CENTER: case Input.Keys.ENTER: return true; default: return false; } }
Example #30
Source File: ControllerMenuStage.java From gdx-controllerutils with Apache License 2.0 | 5 votes |
/** * returns true if the given keyCode is a EscapeAction key/button. You can override this. */ public boolean isEscapeActionKeyCode(int keyCode) { switch (keyCode) { case Input.Keys.BACK: case Input.Keys.BACKSPACE: case Input.Keys.ESCAPE: return true; default: return false; } }