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;
MusicSelectionPage ms;
AnalyzePage ap;
public AnalyzePage ap;
private Vector3 cameraPos;
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.utils.ChangeListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.screens.PreGameScreen;
import zero1hd.rhythmbullet.ui.builders.HealthBar;
import zero1hd.rhythmbullet.ui.windows.FPSWindow;
import zero1hd.rhythmbullet.ui.windows.PauseMenu;
import zero1hd.rhythmbullet.util.MiniEvents;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GameHUD extends Stage {
private PreGameScreen pgs;
private Label scoreLabel;
private ImageButton pause;
private boolean paused;
@ -39,14 +43,15 @@ public class GameHUD extends Stage {
private ScoreManager sm;
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();
scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE);
scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f);
addActor(scoreLabel);
this.sm = gpa.score;
this.gpa = gpa;
this.pgs = preGS;
pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
@ -69,6 +74,14 @@ public class GameHUD extends Stage {
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);
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);
addActor(healthBar);
healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
pixmap = new Pixmap(3, 3, Format.RGBA8888);
int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth();
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 {
private Label label;
private TextButton resumeButton;
private TextButton quit;
public PauseMenu(Skin skin) {
super("Paused", skin, "tinted");
defaults().pad(25f);
@ -16,9 +16,10 @@ public class PauseMenu extends Window {
add(label).spaceBottom(15f);
row();
resumeButton = new TextButton("Resume", skin);
add(resumeButton);
resumeButton = new TextButton("Resume", skin, "sub");
add(resumeButton).spaceBottom(8f);
quit = new TextButton("Quit", skin, "sub");
add(quit);
pack();
setModal(true);
@ -28,4 +29,7 @@ public class PauseMenu extends Window {
public TextButton getResumeButton() {
return resumeButton;
}
public TextButton getQuitButton() {
return quit;
}
}