Revision | a9ba9e76724a2c0fe90c499e676ae3eb797dbc5e (tree) |
---|---|
Zeit | 2022-01-10 02:40:15 |
Autor | sebastian_bugiu |
Commiter | sebastian_bugiu |
Cosmetic changes. Readded difficulty selection menu.
@@ -41,11 +41,12 @@ | ||
41 | 41 | String creditsString = "SPACEROCKET\n" + |
42 | 42 | "Programmed by Sebastian Bugiu\n" + |
43 | 43 | "Art by Alex Bratu\n" + |
44 | + "Powered by libGDX\n" + | |
44 | 45 | "Headway Tech Copyright 2009 - 2022"; |
45 | 46 | titleLabel.setText("Credits"); |
46 | 47 | creditsLabel.setText(creditsString); |
47 | 48 | |
48 | - final TextButton backButton = new TextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
49 | + final TextButton backButton = Utility.createTextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
49 | 50 | backButton.addListener(new ChangeListener() { |
50 | 51 | @Override |
51 | 52 | public void changed(ChangeEvent event, Actor actor) { |
@@ -99,7 +99,7 @@ | ||
99 | 99 | ScrollPane scrollPane = new ScrollPane(label, skin); |
100 | 100 | scrollPane.setScrollingDisabled(true, false); |
101 | 101 | |
102 | - final TextButton backButton = new TextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
102 | + final TextButton backButton = Utility.createTextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
103 | 103 | backButton.addListener(new ChangeListener() { |
104 | 104 | @Override |
105 | 105 | public void changed(ChangeEvent event, Actor actor) { |
@@ -107,7 +107,7 @@ | ||
107 | 107 | table.row().pad(10, 10, 0, 10); |
108 | 108 | } |
109 | 109 | |
110 | - final TextButton backButton = new TextButton("Done", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
110 | + final TextButton backButton = Utility.createTextButton("Done", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
111 | 111 | backButton.addListener(new ChangeListener() { |
112 | 112 | @Override |
113 | 113 | public void changed(ChangeEvent event, Actor actor) { |
@@ -6,10 +6,12 @@ | ||
6 | 6 | import com.badlogic.gdx.graphics.OrthographicCamera; |
7 | 7 | import com.badlogic.gdx.scenes.scene2d.Actor; |
8 | 8 | import com.badlogic.gdx.scenes.scene2d.Stage; |
9 | +import com.badlogic.gdx.scenes.scene2d.ui.Label; | |
9 | 10 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; |
10 | 11 | import com.badlogic.gdx.scenes.scene2d.ui.Table; |
11 | 12 | import com.badlogic.gdx.scenes.scene2d.ui.TextButton; |
12 | 13 | import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; |
14 | +import com.badlogic.gdx.utils.Align; | |
13 | 15 | import com.badlogic.gdx.utils.ScreenUtils; |
14 | 16 | import com.badlogic.gdx.utils.viewport.ScreenViewport; |
15 | 17 |
@@ -36,29 +38,34 @@ | ||
36 | 38 | Skin skin = new Skin(Gdx.files.internal("uiskin.json")); |
37 | 39 | |
38 | 40 | //create buttons |
39 | - TextButton resumeGame = new TextButton("Resume Game", skin); | |
40 | - TextButton newGame = new TextButton("New Game", skin); | |
41 | - TextButton preferences = new TextButton("Preferences", skin); | |
42 | - TextButton highScore = new TextButton("High Score", skin); | |
43 | - TextButton help = new TextButton("How to play", skin); | |
44 | - TextButton credits = new TextButton("Credits", skin); | |
45 | - TextButton exit = new TextButton("Exit", skin); | |
41 | + Label title = new Label("HotShot", skin); | |
42 | + title.setAlignment(Align.center); | |
43 | + title.setFontScale(2.0f); | |
44 | + TextButton resumeGame = Utility.createTextButton("Resume Game", skin); | |
45 | + TextButton newGame = Utility.createTextButton("New Game", skin); | |
46 | + TextButton preferences = Utility.createTextButton("Preferences", skin); | |
47 | + TextButton highScore = Utility.createTextButton("High Score", skin); | |
48 | + TextButton help = Utility.createTextButton("How to play", skin); | |
49 | + TextButton credits = Utility.createTextButton("Credits", skin); | |
50 | + TextButton exit = Utility.createTextButton("Exit", skin); | |
46 | 51 | |
52 | + table.add(title).fillX().uniformX(); | |
53 | + table.row().pad(20, 20, 0, 20); | |
47 | 54 | //add buttons to table |
48 | 55 | if (SpaceRocket.getGame().isSessionResumeAvailable()) { |
49 | 56 | table.add(resumeGame).fillX().uniformX(); |
50 | - table.row().pad(10, 0, 0, 0); | |
57 | + table.row().pad(10, 20, 0, 20); | |
51 | 58 | } |
52 | 59 | table.add(newGame).fillX().uniformX(); |
53 | - table.row().pad(10, 0, 0, 0); | |
60 | + table.row().pad(10, 20, 0, 20); | |
54 | 61 | table.add(preferences).fillX().uniformX(); |
55 | - table.row().pad(10, 0, 0, 0); | |
62 | + table.row().pad(10, 20, 0, 20); | |
56 | 63 | table.add(highScore).fillX().uniformX(); |
57 | - table.row().pad(10, 0, 0, 0); | |
64 | + table.row().pad(10, 20, 0, 20); | |
58 | 65 | table.add(help).fillX().uniformX(); |
59 | - table.row().pad(10, 0, 0, 0); | |
66 | + table.row().pad(10, 20, 0, 20); | |
60 | 67 | table.add(credits).fillX().uniformX(); |
61 | - table.row().pad(10, 0, 0, 0); | |
68 | + table.row().pad(10, 20, 0, 20); | |
62 | 69 | table.add(exit).fillX().uniformX(); |
63 | 70 | |
64 | 71 | // create button listeners |
@@ -88,7 +88,7 @@ | ||
88 | 88 | }); |
89 | 89 | |
90 | 90 | |
91 | - final TextButton backButton = new TextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
91 | + final TextButton backButton = Utility.createTextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
92 | 92 | backButton.addListener(new ChangeListener() { |
93 | 93 | @Override |
94 | 94 | public void changed(ChangeEvent event, Actor actor) { |
@@ -2,6 +2,8 @@ | ||
2 | 2 | |
3 | 3 | import com.badlogic.gdx.graphics.g2d.Sprite; |
4 | 4 | import com.badlogic.gdx.graphics.g2d.TextureRegion; |
5 | +import com.badlogic.gdx.scenes.scene2d.ui.Skin; | |
6 | +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | |
5 | 7 | |
6 | 8 | public class Utility { |
7 | 9 |
@@ -51,4 +53,10 @@ | ||
51 | 53 | public static float clamp(float val, float min, float max) { |
52 | 54 | return Math.max(min, Math.min(max, val)); |
53 | 55 | } |
56 | + | |
57 | + public static TextButton createTextButton(String text, Skin skin) { | |
58 | + TextButton textButton = new TextButton(text, skin); | |
59 | + textButton.pad(10.0f); | |
60 | + return textButton; | |
61 | + } | |
54 | 62 | } |
@@ -4,13 +4,16 @@ | ||
4 | 4 | import com.badlogic.gdx.ScreenAdapter; |
5 | 5 | import com.badlogic.gdx.scenes.scene2d.Actor; |
6 | 6 | import com.badlogic.gdx.scenes.scene2d.Stage; |
7 | +import com.badlogic.gdx.scenes.scene2d.ui.Label; | |
7 | 8 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; |
8 | 9 | import com.badlogic.gdx.scenes.scene2d.ui.Table; |
9 | 10 | import com.badlogic.gdx.scenes.scene2d.ui.TextButton; |
10 | 11 | import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; |
12 | +import com.badlogic.gdx.utils.Align; | |
11 | 13 | import com.badlogic.gdx.utils.ScreenUtils; |
12 | 14 | import com.badlogic.gdx.utils.viewport.ScreenViewport; |
13 | 15 | import com.headwayent.spacerocket.SpaceRocket; |
16 | +import com.headwayent.spacerocket.Utility; | |
14 | 17 | |
15 | 18 | /** |
16 | 19 | * |
@@ -49,7 +52,6 @@ | ||
49 | 52 | |
50 | 53 | public DifficultySelection() { |
51 | 54 | stage = new Stage(new ScreenViewport()); |
52 | - Gdx.input.setInputProcessor(stage); | |
53 | 55 | } |
54 | 56 | |
55 | 57 | public void show() { |
@@ -59,20 +61,37 @@ | ||
59 | 61 | //table.setDebug(true); |
60 | 62 | stage.addActor(table); |
61 | 63 | |
64 | + Gdx.input.setInputProcessor(stage); | |
65 | + | |
62 | 66 | // temporary until we have asset manager in |
63 | 67 | Skin skin = new Skin(Gdx.files.internal("uiskin.json")); |
64 | 68 | |
69 | + Label title = new Label("Select difficulty", skin); | |
70 | + title.setAlignment(Align.center); | |
71 | + title.setFontScale(2.0f); | |
65 | 72 | //create buttons |
66 | - TextButton easy = new TextButton("Easy", skin); | |
67 | - TextButton medium = new TextButton("Medium", skin); | |
68 | - TextButton hard = new TextButton("Hard", skin); | |
73 | + TextButton easy = Utility.createTextButton("Easy", skin); | |
74 | + TextButton medium = Utility.createTextButton("Medium", skin); | |
75 | + TextButton hard = Utility.createTextButton("Hard", skin); | |
76 | + | |
77 | + final TextButton backButton = Utility.createTextButton("Back", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
78 | + backButton.addListener(new ChangeListener() { | |
79 | + @Override | |
80 | + public void changed(ChangeEvent event, Actor actor) { | |
81 | + SpaceRocket.getGame().changeScreen(SpaceRocket.Screen.MAIN_MENU); | |
82 | + } | |
83 | + }); | |
69 | 84 | |
70 | 85 | //add buttons to table |
86 | + table.add(title).fillX().uniformX(); | |
87 | + table.row().pad(20, 20, 0, 20); | |
71 | 88 | table.add(easy).fillX().uniformX(); |
72 | - table.row().pad(10, 0, 10, 0); | |
89 | + table.row().pad(10, 20, 0, 20); | |
73 | 90 | table.add(medium).fillX().uniformX(); |
74 | - table.row(); | |
91 | + table.row().pad(10, 20, 0, 20); | |
75 | 92 | table.add(hard).fillX().uniformX(); |
93 | + table.row().pad(10, 20, 0, 20); | |
94 | + table.add(backButton).fillX().uniformX(); | |
76 | 95 | |
77 | 96 | final SpaceRocket game = SpaceRocket.getGame(); |
78 | 97 | easy.addListener(new ChangeListener() { |
@@ -102,9 +121,9 @@ | ||
102 | 121 | } |
103 | 122 | }); |
104 | 123 | |
105 | - difficulty = Difficulty.HARD; | |
106 | - game.changeScreen(SpaceRocket.Screen.IN_GAME); | |
107 | - startGame(); | |
124 | +// difficulty = Difficulty.HARD; | |
125 | +// game.changeScreen(SpaceRocket.Screen.IN_GAME); | |
126 | +// startGame(); | |
108 | 127 | } |
109 | 128 | |
110 | 129 | @Override |