progress on integration of score manager
This commit is contained in:
parent
29c30290fb
commit
85117f74aa
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user