progress on integration of score manager

This commit is contained in:
Harrison Deng 2017-08-08 02:34:08 -05:00
parent 29c30290fb
commit 85117f74aa
2 changed files with 19 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.ui.builders.HealthBar;
import zero1hd.rhythmbullet.ui.windows.FPSWindow;
import zero1hd.rhythmbullet.ui.windows.PauseMenu;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GameHUD extends Stage {
private Label scoreLabel;
@ -26,13 +27,13 @@ public class GameHUD extends Stage {
private Image leftStatusBar;
private Image rightStatusBar;
private Music music;
private ScoreManager sm;
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) {
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;
pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
@ -77,6 +78,14 @@ public class GameHUD extends Stage {
setStatusColor(1, 1, 1, 0.5f);
}
@Override
public void act(float delta) {
if (sm.checkDifferent()) {
setScore(sm.getScore());
}
super.act(delta);
}
/**
* sets the label for scoring to the designated score
* @param score designated score

View File

@ -1,7 +1,8 @@
package zero1hd.rhythmbullet.util;
public class ScoreManager {
public int score;
private int score;
private boolean different;
public void setScore(int score) {
this.score = score;
@ -14,4 +15,10 @@ public class ScoreManager {
public void addScore(int addedScore) {
score += addedScore;
}
public boolean checkDifferent() {
boolean current = different;
different = false;
return current;
}
}