From 3c79bdcb32cfbc3b9952682d5b7f1aec26f9f7fa Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 4 Aug 2017 14:25:50 -0500 Subject: [PATCH] fixed gl context issue --- .../rhythmbullet/ui/pages/AnalyzePage.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java index 8690ad8..7364b0e 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java @@ -28,6 +28,8 @@ import zero1hd.rhythmbullet.util.MiniEvents; import zero1hd.rhythmbullet.util.MiniListener; public class AnalyzePage extends Page implements MiniListener { + private AnalyzePage ap = this; + AudioAnalyzer audioAnalyzer; AudioData music; RhythmMapAlgorithm mapGenAlgorithm; @@ -55,7 +57,7 @@ public class AnalyzePage extends Page implements MiniListener { private long startTime, endTime; private Thread mapGenThread; - private GameScreen gameScreen; + private volatile GameScreen gameScreen; private RhythmBullet core; @@ -262,11 +264,17 @@ public class AnalyzePage extends Page implements MiniListener { case MUSIC_DATA_CLEANED: info[3].setText("data cleaning done."); info[4].addAction(Actions.color(Color.BLACK, 0.75f)); - gameScreen = new GameScreen(core); - mapGenAlgorithm = new RhythmMapAlgorithm(gameScreen.getGameArea().em, gameScreen.getGameArea().cm, audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue()); - mapGenAlgorithm.getSender().addListener(this); - mapGenThread = new Thread(mapGenAlgorithm); - mapGenThread.start(); + Gdx.app.postRunnable(new Runnable() { + @Override + public void run() { + gameScreen = new GameScreen(core); + mapGenAlgorithm = new RhythmMapAlgorithm(gameScreen.getGameArea().em, gameScreen.getGameArea().cm, audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue()); + mapGenAlgorithm.getSender().addListener(ap); + mapGenThread = new Thread(mapGenAlgorithm); + mapGenThread.start(); + } + }); + startTime = System.currentTimeMillis(); break; case MAPGEN_ITERATED: @@ -275,25 +283,19 @@ public class AnalyzePage extends Page implements MiniListener { case MAP_GENERATED: endTime = System.currentTimeMillis(); info[5].setText("Done. Generation time: " + ((endTime - startTime)/1000f) + "s"); - - Gdx.app.postRunnable(new Runnable() { + beginButton.addListener(new ChangeListener() { + @Override - public void run() { - beginButton.addListener(new ChangeListener() { - - @Override - public void changed(ChangeEvent event, Actor actor) { - gameScreen.setGamePlayMap(mapGenAlgorithm.getMap()); - core.setScreen(gameScreen); - } - }); + public void changed(ChangeEvent event, Actor actor) { + gameScreen.setGamePlayMap(mapGenAlgorithm.getMap()); + core.setScreen(gameScreen); } }); info[5].addAction(Actions.color(Color.BLACK, 0.75f)); - songInfo.addAction(Actions.moveTo(songInfo.getX(), getHeightBelowTitle()-songInfo.getHeight(), 0.75f, Interpolation.linear)); - difficultyTable.addAction(Actions.sequence(Actions.delay(0.4f), Actions.moveTo(songInfo.getX(), getHeightBelowTitle()-songInfo.getHeight()-difficultyTable.getHeight()-10f,0.8f, Interpolation.linear))); - beginTable.addAction(Actions.sequence(Actions.delay(0.5f), Actions.moveTo(difficultyTable.getX(), getHeightBelowTitle()-songInfo.getHeight()-difficultyTable.getHeight()-beginTable.getHeight()-20f,0.8f, Interpolation.linear))); + songInfo.addAction(Actions.moveTo(songInfo.getX(), getHeight()-songInfo.getHeight()-10, 0.55f, Interpolation.linear)); + difficultyTable.addAction(Actions.sequence(Actions.delay(0.3f), Actions.moveTo(songInfo.getX(), getHeight()-songInfo.getHeight()-10-difficultyTable.getHeight()-5f,0.8f, Interpolation.linear))); + beginTable.addAction(Actions.sequence(Actions.delay(0.5f), Actions.moveTo(difficultyTable.getX(), getHeight()-songInfo.getHeight()-10-difficultyTable.getHeight()-beginTable.getHeight()-10f,0.8f, Interpolation.linear))); default: break; }