Skip to content
Snippets Groups Projects
Commit 35541bd7 authored by Elias Fierke's avatar Elias Fierke
Browse files

[feat:] coin amount display

parent 5428f3f7
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
......@@ -36,18 +37,32 @@ public class GameStage extends Stage {
private boolean isGameOver;
private Table gameOverMenu;
public Label scoreLabel;
public Label coinLabel;
public Image coinImage;
//public static BackgroundPool background_pool = new BackgroundPool();
public GameStage() {
SoundManager.getInstance().playMusic("soundtracks/main_game.wav", true);
BitmapFont font = new BitmapFont();
font.getData().setScale(3);
Label.LabelStyle defaultLabelStyle = new Label.LabelStyle();
defaultLabelStyle.font = font;
scoreLabel = new Label("Score: 0", defaultLabelStyle);
scoreLabel.setPosition(5,getHeight()-scoreLabel.getHeight()-5);
scoreLabel.setPosition(10,getHeight()-scoreLabel.getHeight()-10);
addActor(scoreLabel);
coinImage = new Image(new Texture("icon/coin.png"));
coinImage.setPosition(getWidth() - coinImage.getWidth() - 10, getHeight()-coinImage.getHeight()-10);
coinLabel = new Label("0", defaultLabelStyle);
coinLabel.setPosition(getWidth() - coinImage.getWidth() - coinLabel.getWidth() - 20, getHeight()-coinLabel.getHeight()-10);
addActor(coinLabel);
addActor(coinImage);
ship = new SpaceShip();
addActor(ship);
enemies = new Array<>();
......@@ -127,6 +142,8 @@ public class GameStage extends Stage {
coin.remove();
coins.removeValue(coin, true);
SoundManager.getInstance().playSound("sounds/coin.mp3");
coinLabel.setText(ship.coins);
coinLabel.setPosition(getWidth() - coinImage.getWidth() - coinLabel.getWidth() - 20, getHeight()-coinLabel.getHeight()-10);
}
}
for (Enemy enemy : enemies) {
......@@ -212,6 +229,7 @@ public class GameStage extends Stage {
if (event.isHandled()) {
System.out.println("Start...");
Navigator.game.setScreen(new MainMenu());
//SoundManager.getInstance().fadeOutMusic(2);
}
return false;
});
......@@ -221,6 +239,7 @@ public class GameStage extends Stage {
if (event.isHandled()) {
System.out.println("Start...");
Navigator.game.setScreen(new ShopMenu());
//SoundManager.getInstance().fadeOutMusic(2);
}
return false;
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment