• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiona4aa851902309bf1de4c959b32e6674abdcece85 (tree)
Time2022-01-10 00:43:40
Authorsebastian_bugiu
Commitersebastian_bugiu

Log Message

Added save/resume game.

Change Summary

Incremental Difference

diff -r 3e6f85ec4103 -r a4aa85190230 core/src/com/headwayent/spacerocket/HighScoreActivity.java
--- a/core/src/com/headwayent/spacerocket/HighScoreActivity.java Fri Jan 07 22:01:56 2022 +0200
+++ b/core/src/com/headwayent/spacerocket/HighScoreActivity.java Sun Jan 09 17:43:40 2022 +0200
@@ -12,12 +12,9 @@
1212 import com.badlogic.gdx.utils.ScreenUtils;
1313 import com.badlogic.gdx.utils.viewport.ScreenViewport;
1414 import com.headwayent.spacerocket.old.DifficultySelection;
15-import com.headwayent.spacerocket.old.ExtendedCanvas;
1615 import com.headwayent.spacerocket.old.Status;
1716
18-import java.util.ArrayList;
1917 import java.util.Comparator;
20-import java.util.HashMap;
2118 import java.util.TreeMap;
2219
2320 public class HighScoreActivity extends ScreenAdapter {
@@ -139,7 +136,7 @@
139136 private void saveScore(String userName) {
140137 SpaceRocket gameEngine = SpaceRocket.getGame();
141138 if (gameEngine.getGameMode() == SpaceRocket.GameMode.SP) {
142- gameEngine.SaveGame(userName);
139+ gameEngine.saveGame(userName);
143140 }
144141 Status status = gameEngine.getCanvas().getStatus();
145142 String msg = "Congratulations! You have reached a new " +
diff -r 3e6f85ec4103 -r a4aa85190230 core/src/com/headwayent/spacerocket/MainMenuActivity.java
--- a/core/src/com/headwayent/spacerocket/MainMenuActivity.java Fri Jan 07 22:01:56 2022 +0200
+++ b/core/src/com/headwayent/spacerocket/MainMenuActivity.java Sun Jan 09 17:43:40 2022 +0200
@@ -36,6 +36,7 @@
3636 Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
3737
3838 //create buttons
39+ TextButton resumeGame = new TextButton("Resume Game", skin);
3940 TextButton newGame = new TextButton("New Game", skin);
4041 TextButton preferences = new TextButton("Preferences", skin);
4142 TextButton highScore = new TextButton("High Score", skin);
@@ -44,6 +45,10 @@
4445 TextButton exit = new TextButton("Exit", skin);
4546
4647 //add buttons to table
48+ if (SpaceRocket.getGame().isSessionResumeAvailable()) {
49+ table.add(resumeGame).fillX().uniformX();
50+ table.row().pad(10, 0, 0, 0);
51+ }
4752 table.add(newGame).fillX().uniformX();
4853 table.row().pad(10, 0, 0, 0);
4954 table.add(preferences).fillX().uniformX();
@@ -64,6 +69,14 @@
6469 }
6570 });
6671
72+ resumeGame.addListener(new ChangeListener() {
73+ @Override
74+ public void changed(ChangeEvent event, Actor actor) {
75+ SpaceRocket.getGame().changeScreen(SpaceRocket.Screen.IN_GAME);
76+ SpaceRocket.getGame().resumeSession();
77+ }
78+ });
79+
6780 newGame.addListener(new ChangeListener() {
6881 @Override
6982 public void changed(ChangeEvent event, Actor actor) {
diff -r 3e6f85ec4103 -r a4aa85190230 core/src/com/headwayent/spacerocket/SpaceRocket.java
--- a/core/src/com/headwayent/spacerocket/SpaceRocket.java Fri Jan 07 22:01:56 2022 +0200
+++ b/core/src/com/headwayent/spacerocket/SpaceRocket.java Sun Jan 09 17:43:40 2022 +0200
@@ -96,6 +96,7 @@
9696 @Override
9797 public void dispose () {
9898 super.dispose();
99+ saveSession();
99100 batch.dispose();
100101 mainTextureAtlas.dispose();
101102 }
@@ -216,7 +217,11 @@
216217 save.writeBytes(b, false);
217218 }
218219
219- private void resumeSession() {
220+ public boolean isSessionResumeAvailable() {
221+ return Gdx.files.local("save").exists();
222+ }
223+
224+ public void resumeSession() {
220225 FileHandle save = Gdx.files.local("save");
221226
222227 canvas.getGraphicsManager().playSingle();
@@ -244,10 +249,11 @@
244249 xPos = Math.round(xPosF * ExtendedCanvas.getScreenWidth());
245250 yPos = Math.round(yPosF * ExtendedCanvas.getScreenHeight());
246251 canvas.load(xPos, yPos, score, lives, currentBoss, bossHealth);
252+ save.delete();
247253 }
248254 }
249255
250- public void SaveGame(String userName) {
256+ public void saveGame(String userName) {
251257 if (userName == null || "".equals(userName)) {
252258 return;
253259 }
diff -r 3e6f85ec4103 -r a4aa85190230 ios/robovm.properties
--- a/ios/robovm.properties Fri Jan 07 22:01:56 2022 +0200
+++ b/ios/robovm.properties Sun Jan 09 17:43:40 2022 +0200
@@ -2,5 +2,5 @@
22 app.id=com.headwayent.spacerocket
33 app.mainclass=com.headwayent.spacerocket.IOSLauncher
44 app.executable=IOSLauncher
5-app.build=5
5+app.build=6
66 app.name=Hotshot 2D