|
6 | 6 | import com.badlogic.gdx.graphics.g2d.TextureRegion; |
7 | 7 | import com.badlogic.gdx.graphics.g2d.NinePatch; |
8 | 8 | import com.badlogic.gdx.scenes.scene2d.Actor; |
9 | | -import com.badlogic.gdx.scenes.scene2d.ui.Image; |
10 | | -import com.badlogic.gdx.scenes.scene2d.ui.Table; |
11 | | -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; |
| 9 | +import com.badlogic.gdx.scenes.scene2d.ui.*; |
12 | 10 | import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; |
13 | 11 | import com.csse3200.game.areas.ForestGameArea; |
14 | 12 | import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle; |
@@ -53,7 +51,20 @@ private void addActors() { |
53 | 51 | TextButton loadBtn = new TextButton("Continue", customButtonStyle); |
54 | 52 | TextButton settingsBtn = new TextButton("Settings", customButtonStyle); |
55 | 53 | TextButton exitBtn = new TextButton("Exit", customButtonStyle); |
56 | | - |
| 54 | + |
| 55 | + // stars display |
| 56 | + Image starImage = new Image( |
| 57 | + ServiceLocator.getResourceService().getAsset( |
| 58 | + "images/star.png", |
| 59 | + Texture.class |
| 60 | + ) |
| 61 | + ); |
| 62 | + Label starsLabel = new Label( |
| 63 | + Integer.toString(ServiceLocator.getGameStateService().getStars()), |
| 64 | + skin, |
| 65 | + "large" |
| 66 | + ); |
| 67 | + |
57 | 68 | // 设置按钮大小 |
58 | 69 | float buttonWidth = 200f; |
59 | 70 | float buttonHeight = 50f; |
@@ -103,7 +114,13 @@ public void changed(ChangeEvent changeEvent, Actor actor) { |
103 | 114 | }); |
104 | 115 |
|
105 | 116 |
|
106 | | - table.add().expandY().row(); |
| 117 | + table.add().expandY().row(); |
| 118 | + HorizontalGroup group = new HorizontalGroup(); |
| 119 | + group.space(5); |
| 120 | + group.addActor(starImage); |
| 121 | + group.addActor(starsLabel); |
| 122 | + table.add(group); |
| 123 | + table.row(); |
107 | 124 | table.add(startBtn).size(buttonWidth, buttonHeight).padTop(50f); |
108 | 125 | table.row(); |
109 | 126 | table.add(loadBtn).size(buttonWidth, buttonHeight).padTop(20f); |
|
0 commit comments