public void update(float deltaTime) { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (OverlapTester.pointInRectangle(playBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new GameScreen(game)); return; } if (OverlapTester.pointInRectangle(highscoresBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new HighscoresScreen(game)); return; } if (OverlapTester.pointInRectangle(helpBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new HelpScreen(game)); return; } if (OverlapTester.pointInRectangle(soundBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); Settings.soundEnabled = !Settings.soundEnabled; if (Settings.soundEnabled) Assets.music.play(); else Assets.music.pause(); } } }
private void updatePaused() { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (OverlapTester.pointInRectangle(resumeBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); state = GAME_RUNNING; return; } if (OverlapTester.pointInRectangle(quitBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new MainMenuScreen(game)); return; } } }
public void update(float deltaTime) { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (OverlapTester.pointInRectangle(nextBounds, touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new MainMenuScreen(game)); return; } } }
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(); } }