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.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.ScoreManager;
|
||||||
|
|
||||||
public class GameHUD extends Stage {
|
public class GameHUD extends Stage {
|
||||||
private Label scoreLabel;
|
private Label scoreLabel;
|
||||||
@ -26,13 +27,13 @@ public class GameHUD extends Stage {
|
|||||||
private Image leftStatusBar;
|
private Image leftStatusBar;
|
||||||
private Image rightStatusBar;
|
private Image rightStatusBar;
|
||||||
private Music music;
|
private Music music;
|
||||||
|
private ScoreManager sm;
|
||||||
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) {
|
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) {
|
||||||
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;
|
||||||
pause = new ImageButton(skin.getDrawable("pause"),
|
pause = new ImageButton(skin.getDrawable("pause"),
|
||||||
skin.getDrawable("pause-down"));
|
skin.getDrawable("pause-down"));
|
||||||
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
|
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
|
||||||
@ -77,6 +78,14 @@ public class GameHUD extends Stage {
|
|||||||
setStatusColor(1, 1, 1, 0.5f);
|
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
|
* sets the label for scoring to the designated score
|
||||||
* @param score designated score
|
* @param score designated score
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package zero1hd.rhythmbullet.util;
|
package zero1hd.rhythmbullet.util;
|
||||||
|
|
||||||
public class ScoreManager {
|
public class ScoreManager {
|
||||||
public int score;
|
private int score;
|
||||||
|
private boolean different;
|
||||||
|
|
||||||
public void setScore(int score) {
|
public void setScore(int score) {
|
||||||
this.score = score;
|
this.score = score;
|
||||||
@ -14,4 +15,10 @@ public class ScoreManager {
|
|||||||
public void addScore(int addedScore) {
|
public void addScore(int addedScore) {
|
||||||
score += addedScore;
|
score += addedScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkDifferent() {
|
||||||
|
boolean current = different;
|
||||||
|
different = false;
|
||||||
|
return current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user