@Override public int getX () { return input.getX(); }
@Override public int getX (int pointer) { return input.getX(pointer); }
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; }
@Override public void render () { currentPosition = music.getPosition(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(buttons, 0, 0); font.draw(batch, (int)currentPosition / 60 + ":" + (int)currentPosition % 60, 365, 35); batch.end(); sliderUpdating = true; slider.setValue((currentPosition / songDuration) * 100f); sliderUpdating = false; stage.act(); stage.draw(); if (Gdx.input.justTouched()) { if (Gdx.input.getY() > Gdx.graphics.getHeight() - 64) { if (Gdx.input.getX() < 64) { music.play(); } if (Gdx.input.getX() > 64 && Gdx.input.getX() < 128) { music.stop(); } if (Gdx.input.getX() > 128 && Gdx.input.getX() < 192) { music.pause(); } } } }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); renderer.setProjectionMatrix(camera.combined); if (Gdx.input.isTouched()) camera.unproject(globalCoords.set(Gdx.input.getX(), Gdx.input.getY(), 0)); solveFakeIK(globalCoords); renderBones(); }
void triangulate () { // seed = 4139368480425561099l; // seed = 6559652580366669361l; MathUtils.random.setSeed(seed); int pointCount = 100; points.clear(); for (int i = 0; i < pointCount; i++) { float value; do { value = MathUtils.random(10, 400); } while (points.contains(value)); points.add(value); do { value = MathUtils.random(10, 400); } while (points.contains(value)); points.add(value); } points.add(Gdx.input.getX()); points.add(Gdx.graphics.getHeight() - Gdx.input.getY()); triangles = trianglulator.computeTriangles(points, false); }
public void render () { // set the clear color and clear the screen. Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // draw the sprite batch.begin(); batch.draw(texture, spritePosition.x, spritePosition.y); batch.end(); // if a finger is down, set the sprite's x/y coordinate. if (Gdx.input.isTouched()) { // the unproject method takes a Vector3 in window coordinates (origin in // upper left corner, y-axis pointing down) and transforms it to world // coordinates. camera.unproject(spritePosition.set(Gdx.input.getX(), Gdx.input.getY(), 0)); } } }
@Override public void render () { Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); renderer.setProjectionMatrix(camera.combined); renderer.begin(ShapeType.Filled); int size = Math.max(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()) / 10; for (int i = 0; i < 10; i++) { if (!Gdx.input.isTouched(i)) continue; viewport.unproject(tp.set(Gdx.input.getX(i), Gdx.input.getY(i))); Color color = colors[i % colors.length]; renderer.setColor(color); float sSize = size * Gdx.input.getPressure(i); renderer.triangle(tp.x, tp.y + sSize, tp.x + sSize, tp.y - sSize, tp.x - sSize, tp.y - sSize); } renderer.end(); }
stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY())); Actor actor = stage.hit(stageCoords.x, stageCoords.y, true); if (actor != null)
@Override public void render () { // clear the screen, update the camera and make the sprite batch // use its matrices. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); batch.setProjectionMatrix(camera.combined); // render all the things, we render in a y-down // cartesian coordinate system batch.begin(); // drawing a region, x and y will be the top left corner of the region, would be bottom left // with y-up. batch.draw(region, 20, 100); // drawing text, x and y will be the top left corner for text, same as with y-up font.draw(batch, "This is a test", 270, 100); // drawing regions from an atlas, x and y will be the top left corner. // you shouldn't call findRegion every frame, cache the result. batch.draw(atlas.findRegion("badlogicsmall"), 360, 100); // drawing a sprite created from an atlas, FIXME wut?! AtlasSprite#setPosition seems to be wrong sprite.setColor(Color.RED); sprite.draw(batch); // finally we draw our current touch/mouse coordinates font.draw(batch, Gdx.input.getX() + ", " + Gdx.input.getY(), 0, 0); batch.end(); // tell the stage to act and draw itself stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); }
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY())); Actor actor = hit(tempCoords.x, tempCoords.y, true); if (actor == null) return;
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY())); Actor actor = hit(tempCoords.x, tempCoords.y, true); if (actor == null) return;
else renderer.setColor(Color.GREEN); renderer.rect(Gdx.input.getX() - 15, Gdx.graphics.getHeight() - Gdx.input.getY() - 15, 30, 30); renderer.rect(x, y, 30, 30); renderer.end();
batch.draw(tex, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()); font.draw(batch, "" + Gdx.graphics.getWidth() + ", " + Gdx.graphics.getHeight(), 0, 20); batch.end();
@Override public boolean scrolled(final int amount) { eventQueue.offer(GdxMouseInputEvent.getMouseEvent(input.getX(), input.getY(), amount, 0, GdxMouseInputEvent.NO_BUTTON, false, false)); return true; } }
@Override public boolean scrolled(final int amount) { eventQueue.offer(GdxMouseInputEvent.getMouseEvent(input.getX(), input.getY(), amount, 0, GdxMouseInputEvent.NO_BUTTON, false, false)); return true; } }
@Override protected void process(Entity e) { final Pos pos = pm.get(e); aimAtTmp.set(Gdx.input.getX(), Gdx.input.getY(), 0); final Vector3 unproject = cameraSystem.camera.unproject(aimAtTmp); pos.x = unproject.x; pos.y = unproject.y; } }
@Override public void layout() { updateLinesFromModel(); // Manually update hover state { int screenX = Gdx.input.getX(); int screenY = Gdx.input.getY(); Vector2 localCoord = screenToLocalCoordinates(tmpVec2.set(screenX, screenY)); updateLinesHover(localCoord.x, localCoord.y); } }