private void updateRunning(float deltaTime) { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); world.ShotProjectile(); if (OverlapTester.pointInRectangle(pauseBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); state = GAME_PAUSED; return; } else if (Bob.BOB_DOUBLE_JUMP == false) { if (Bob.jumpTime > 0.8f) { Bob.BOB_DOUBLE_JUMP = true; Bob.jumpTime = 0f; } } } ApplicationType appType = Gdx.app.getType(); // should work also with Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer) if (appType == ApplicationType.Android || appType == ApplicationType.iOS) { world.update(deltaTime, Gdx.input.getAccelerometerX()); } else { float accel = 0; if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) accel = 5f; if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) accel = -5f; world.update(deltaTime, accel); } if (world.score != lastScore) { lastScore = world.score; scoreString = "SCORE: " + lastScore; } if (world.state == World.GAME_LEVEL_END) { state = GAME_LEVEL_END; } if (world.state == World.GAME_OVER) { state = GAME_OVER; if (lastScore >= Settings.highscores[4]) scoreString = "NEW HIGHSCORE: " + lastScore; else scoreString = "SCORE: " + lastScore; Settings.addScore(lastScore); Settings.save(); } }
@Override public void pause() { Settings.save(); }