private boolean isTouched (float startX, float endX) { // Check for touch inputs between startX and endX // startX/endX are given between 0 (left edge of the screen) and 1 (right edge of the screen) for (int i = 0; i < 2; i++) { float x = Gdx.input.getX(i) / (float)Gdx.graphics.getWidth(); if (Gdx.input.isTouched(i) && (x >= startX && x <= endX)) { return true; } } return false; }
/** Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new * screen, if any. * @param screen may be {@code null} */ public void setScreen (Screen screen) { if (this.screen != null) this.screen.hide(); this.screen = screen; if (this.screen != null) { this.screen.show(); this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } }
@Override public boolean keyDown (int keycode) { Gdx.app.log("Input Test", "key down: " + keycode); if (keycode == Keys.G) Gdx.input.setCursorCatched(!Gdx.input.isCursorCatched()); return false; }
public InputWrapper (Input input) { this.input = input; this.multiplexer = new InputMultiplexer(); this.multiplexer.addProcessor(this); input.setInputProcessor(multiplexer); }
@Override public void create () { // disable continuous rendering Gdx.graphics.setContinuousRendering(false); Gdx.app.log("DirtyRenderingTest", "created"); }
void setText (HttpResponse httpResponse) { final String newText = httpResponse.getResultAsString(); Gdx.app.postRunnable(new Runnable() { public void run () { text = newText; } }); }
@Override public void handleHttpResponse (HttpResponse httpResponse) { final byte[] bytes = httpResponse.getResult(); Gdx.app.postRunnable(new Runnable() { @Override public void run () { Pixmap pixmap = new Pixmap(bytes, 0, bytes.length); texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true)); } }); }
@Override public void render () { if (Gdx.input.justTouched()) Gdx.app.exit(); }
@Override public void getTextInput (TextInputListener listener, String title, String text, String hint) { Gdx.app.getInput().getTextInput(listener, title, text, hint); }
/** Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new * screen, if any. * @param screen may be {@code null} */ public void setScreen (Screen screen) { if (this.screen != null) this.screen.hide(); this.screen = screen; if (this.screen != null) { this.screen.show(); this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } }