fixed gl context issue

This commit is contained in:
Harrison Deng 2017-08-04 14:25:50 -05:00
parent 0101f0630b
commit 3c79bdcb32

View File

@ -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;
}