@Override public void render() { // mag+=1; /*if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) sprite.translateX(-2f); if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) sprite.translateX(2f);*/ long startTime = System.currentTimeMillis(); // long elapsedTime = 0; if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { time = System.currentTimeMillis(); /*time%=100000000; time%=100000; time/=3;*/ time %= 10000000; Gdx.app.log("elapsedTime: ", time + ""); if ((time - startTime) > 2000) { sprite.setPosition( Gdx.graphics.getWidth() / 2 - sprite.getWidth() / 2, Gdx.graphics.getHeight() / 2 - sprite.getHeight() / 2); } sprite.translateY(1f); } if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { sprite.translateY(-1f); } startTime = System.currentTimeMillis(); /*sprite.setPosition(Gdx.graphics.getWidth() / 2 - sprite.getWidth() / 2, Gdx.graphics.getHeight() / 2 - sprite.getHeight() / 2);*/ /*if(Gdx.input.isButtonPressed(Input.Keys.LEFT)) sprite.setPosition(Gdx.input.getX(),Gdx.graphics.getHeight() - Gdx.input.getY()); if(movingRight) sprite.translateX(1f);*/ Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); time = 0; batch.draw(sprite, sprite.getX(), sprite.getY()); batch.end(); }
@Override public boolean scrolled(int amount) { if (amount > 0) sprite.translateY(1f); if (amount < 0) sprite.translateY(-1f); return false; }