@@ -420,18 +420,21 @@ public void dispose() {
420
420
421
421
textManager .reset ();
422
422
timers .clear ();
423
- currentScene . stopMusic ();
423
+
424
424
currentDialog = null ;
425
425
426
426
transition .reset ();
427
427
428
428
// Clear all pending callbacks
429
429
ActionCallbackQueue .clear ();
430
-
430
+
431
431
// ONLY dispose currentscene because other scenes are already
432
432
// disposed
433
- currentScene .dispose ();
434
- currentScene = null ;
433
+ if (currentScene != null ) {
434
+ currentScene .stopMusic ();
435
+ currentScene .dispose ();
436
+ currentScene = null ;
437
+ }
435
438
436
439
if (cachedScene != null ) {
437
440
cachedScene .dispose ();
@@ -514,7 +517,8 @@ public void newGame() throws Exception {
514
517
/**
515
518
* Try to load the save game if exists. In other case, load the game from
516
519
* XML.
517
- * @throws Exception
520
+ *
521
+ * @throws Exception
518
522
*
519
523
* @throws IOException
520
524
* @throws SAXException
@@ -538,7 +542,8 @@ public void load() throws Exception {
538
542
/**
539
543
* Load the world description. First try to load 'world.json'. If doesn't
540
544
* exists try 'world.xml'.
541
- * @throws IOException
545
+ *
546
+ * @throws IOException
542
547
*/
543
548
public void loadWorldDesc () throws IOException {
544
549
if (EngineAssetManager .getInstance ().getModelFile (EngineAssetManager .WORLD_FILENAME_JSON ).exists ()) {
@@ -616,7 +621,7 @@ public void loadChapter(String chapterName) throws IOException {
616
621
617
622
if (chapterName == null )
618
623
chapterName = initChapter ;
619
-
624
+
620
625
currentChapter = initChapter ;
621
626
622
627
if (EngineAssetManager .getInstance ().getModelFile (chapterName + EngineAssetManager .CHAPTER_EXT ).exists ()) {
@@ -812,7 +817,7 @@ public void write(Json json) {
812
817
json .writeValue ("currentDialog" , currentDialog .getId ());
813
818
}
814
819
815
- if (transition != null )
820
+ if (transition != null )
816
821
json .writeValue ("transition" , transition );
817
822
818
823
json .writeValue ("chapter" , currentChapter );
@@ -836,18 +841,18 @@ public void read(Json json, JsonValue jsonData) {
836
841
for (Scene s : scenes .values ()) {
837
842
s .resetCamera (width , height );
838
843
}
839
-
844
+
840
845
setCurrentScene (initScene );
841
846
} else {
842
847
currentChapter = json .readValue ("chapter" , String .class , jsonData );
843
-
848
+
844
849
try {
845
850
loadChapter (currentChapter );
846
851
} catch (IOException e1 ) {
847
852
EngineLogger .error ("Error Loading Chapter" );
848
853
return ;
849
854
}
850
-
855
+
851
856
// restore the state after loading the model
852
857
SerializationHelper .getInstance ().setMode (Mode .STATE );
853
858
0 commit comments