diff --git a/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java b/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java index f99ec07..eb9ae2a 100755 --- a/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java @@ -1,59 +1,35 @@ package zero1hd.rhythmbullet.screens; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.InputMultiplexer; import com.badlogic.gdx.Preferences; -import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; import zero1hd.rhythmbullet.RhythmBullet; import zero1hd.rhythmbullet.stages.CreativeHUD; -import zero1hd.rhythmbullet.stages.GameHUD; -import zero1hd.rhythmbullet.stages.GamePlayArea; -public class CreativeScreen extends ScreenAdapter { +public class CreativeScreen extends GameScreen { CreativeHUD chud; - GameHUD ghud; - GamePlayArea gamePlayArea; - InputMultiplexer inputs; Preferences prefs; public CreativeScreen(RhythmBullet core, MainMenu mainMenu) { - gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs()); - ghud = new GameHUD(core.getDefaultSkin(), 100f, gamePlayArea, mainMenu, core); - chud = new CreativeHUD(core, mainMenu, gamePlayArea, ghud); - inputs = new InputMultiplexer(chud, ghud, gamePlayArea); + super(core, mainMenu); + chud = new CreativeHUD(core, mainMenu, gameArea, gameHUD); + inputs.addProcessor(chud); this.prefs = core.getPrefs(); } @Override public void show() { - Gdx.input.setInputProcessor(inputs); - gamePlayArea.loadShaders(prefs); super.show(); } @Override public void render(float delta) { - Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1f); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + super.render(delta); - gamePlayArea.getViewport().apply(); - gamePlayArea.act(); - gamePlayArea.draw(); - - ghud.getViewport().apply(); - ghud.act(); - ghud.draw(); - chud.getViewport().apply(); chud.act(); chud.draw(); - super.render(delta); } @Override diff --git a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java index 871d3ed..622df4c 100755 --- a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java @@ -16,15 +16,20 @@ import zero1hd.rhythmbullet.stages.GameHUD; import zero1hd.rhythmbullet.stages.GamePlayArea; public class GameScreen extends ScreenAdapter { - private GamePlayArea gameArea; - private GameHUD gameHUD; - private InputMultiplexer inputs; - + protected GamePlayArea gameArea; + public GameHUD gameHUD; + + protected InputMultiplexer inputs; public RhythmBullet core; private CoreMusicInfo music; + /** + * The game screen where the game play area, and hud are placed. + * @param core The game context object + * @param screen the screen to return to if player decides to press "quit" button. + */ public GameScreen(RhythmBullet core, Screen screen) { this.core = core; @@ -56,20 +61,14 @@ public class GameScreen extends ScreenAdapter { @Override public void show() { - if (music == null) new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen..."); Gdx.input.setInputProcessor(inputs); gameArea.loadShaders(core.getPrefs()); - - if (!gameHUD.isPaused()) { - music.getPlaybackMusic().play(); - } - super.show(); } @Override public void render(float delta) { - Gdx.gl.glClearColor(0f, 0f, 0f, 0f); + Gdx.gl.glClearColor(0f, 0f, 0f, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); //actual game and hud if (!gameHUD.isPaused()) { @@ -80,10 +79,11 @@ public class GameScreen extends ScreenAdapter { gameHUD.act(delta); } gameArea.getViewport().apply(); + gameArea.draw(); gameHUD.getViewport().apply(); gameHUD.draw(); - if (!music.getPlaybackMusic().isPlaying()) { + if (music != null && !music.getPlaybackMusic().isPlaying()) { end(true); } @@ -122,4 +122,12 @@ public class GameScreen extends ScreenAdapter { public GamePlayArea getGameArea() { return gameArea; } + + public void play() { + if (music == null) throw new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen..."); + Gdx.input.setInputProcessor(inputs); + if (!gameHUD.isPaused()) { + music.getPlaybackMusic().play(); + } + } } \ No newline at end of file