added quit button to pause menu

This commit is contained in:
Harrison Deng 2017-08-18 03:03:18 -05:00
parent 1af07188e6
commit 41b90f3311
3 changed files with 24 additions and 8 deletions

View File

@ -21,7 +21,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
Stage stage; Stage stage;
MusicSelectionPage ms; MusicSelectionPage ms;
AnalyzePage ap; public AnalyzePage ap;
private Vector3 cameraPos; private Vector3 cameraPos;
private RhythmBullet core; private RhythmBullet core;

View File

@ -17,12 +17,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.screens.PreGameScreen;
import zero1hd.rhythmbullet.ui.builders.HealthBar; import zero1hd.rhythmbullet.ui.builders.HealthBar;
import zero1hd.rhythmbullet.ui.windows.FPSWindow; import zero1hd.rhythmbullet.ui.windows.FPSWindow;
import zero1hd.rhythmbullet.ui.windows.PauseMenu; import zero1hd.rhythmbullet.ui.windows.PauseMenu;
import zero1hd.rhythmbullet.util.MiniEvents;
import zero1hd.rhythmbullet.util.ScoreManager; import zero1hd.rhythmbullet.util.ScoreManager;
public class GameHUD extends Stage { public class GameHUD extends Stage {
private PreGameScreen pgs;
private Label scoreLabel; private Label scoreLabel;
private ImageButton pause; private ImageButton pause;
private boolean paused; private boolean paused;
@ -39,13 +43,14 @@ public class GameHUD extends Stage {
private ScoreManager sm; private ScoreManager sm;
private Color original, bass, um; private Color original, bass, um;
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) { public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa, PreGameScreen preGS, final RhythmBullet core) {
super(); super();
scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE); scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE);
scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f); scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f);
addActor(scoreLabel); addActor(scoreLabel);
this.sm = gpa.score; this.sm = gpa.score;
this.gpa = gpa; this.gpa = gpa;
this.pgs = preGS;
pause = new ImageButton(skin.getDrawable("pause"), pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down")); skin.getDrawable("pause-down"));
@ -69,6 +74,14 @@ public class GameHUD extends Stage {
setPaused(false); setPaused(false);
} }
}); });
pauseMenu.getQuitButton().addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
pgs.ap.miniSender.send(MiniEvents.BACK);
core.setScreen(pgs);
}
});
pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f); pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f);
healthBar = new HealthBar(skin, maxHealth); healthBar = new HealthBar(skin, maxHealth);
@ -77,7 +90,6 @@ public class GameHUD extends Stage {
healthBar.setPosition(Gdx.graphics.getWidth() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f); healthBar.setPosition(Gdx.graphics.getWidth() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
addActor(healthBar); addActor(healthBar);
healthBar.setPolyjetEntity(gpa.getPolyjetEntity()); healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
pixmap = new Pixmap(3, 3, Format.RGBA8888); pixmap = new Pixmap(3, 3, Format.RGBA8888);
int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth(); int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth();
Gdx.app.debug("GHUD", "offset on size: " + excess); Gdx.app.debug("GHUD", "offset on size: " + excess);

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window;
public class PauseMenu extends Window { public class PauseMenu extends Window {
private Label label; private Label label;
private TextButton resumeButton; private TextButton resumeButton;
private TextButton quit;
public PauseMenu(Skin skin) { public PauseMenu(Skin skin) {
super("Paused", skin, "tinted"); super("Paused", skin, "tinted");
defaults().pad(25f); defaults().pad(25f);
@ -16,9 +16,10 @@ public class PauseMenu extends Window {
add(label).spaceBottom(15f); add(label).spaceBottom(15f);
row(); row();
resumeButton = new TextButton("Resume", skin); resumeButton = new TextButton("Resume", skin, "sub");
add(resumeButton); add(resumeButton).spaceBottom(8f);
quit = new TextButton("Quit", skin, "sub");
add(quit);
pack(); pack();
setModal(true); setModal(true);
@ -28,4 +29,7 @@ public class PauseMenu extends Window {
public TextButton getResumeButton() { public TextButton getResumeButton() {
return resumeButton; return resumeButton;
} }
public TextButton getQuitButton() {
return quit;
}
} }