proper disposal issue fixed; error while screen is not paused but not
renrendering (ex. dragging window) fixed;
This commit is contained in:
parent
f2a60ea490
commit
30567e086c
@ -193,13 +193,13 @@ public class RhythmBullet extends Game {
|
||||
public void dispose() {
|
||||
Gdx.app.debug("Core", "disposing...");
|
||||
try {
|
||||
getScreen().dispose();
|
||||
skinAtlas.dispose();
|
||||
getSkin().dispose();
|
||||
assetManager.dispose();
|
||||
getScreen().dispose();
|
||||
assetPack.dispose();
|
||||
} catch (NullPointerException npe) {
|
||||
//Means the game was closed before everything was initiated.
|
||||
Gdx.app.debug("Core", "Disposal error occurred, possibly caused by failing to complete initialization.", npe);
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
@ -113,9 +113,12 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
}
|
||||
|
||||
private void synchronizeBufferWithPlayback() {
|
||||
int bufferPos = calcBufferPosition();
|
||||
if (bufferPos <= playingBuffer.limit()) {
|
||||
playingBuffer.position(calcBufferPosition());
|
||||
windowsRead = (int) ((mc.getCurrentPosition() * sampleRate) / windowSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void setMusic() {
|
||||
Gdx.app.debug("PCMObtainer", "music set.");
|
||||
@ -159,8 +162,6 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
private volatile boolean run = true;
|
||||
private long timeOfLastRead;
|
||||
private long waitTime;
|
||||
private int syncC, normC;
|
||||
private float syncPercentage;
|
||||
@Override
|
||||
public void run() {
|
||||
while (run) {
|
||||
@ -184,13 +185,8 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
}
|
||||
if (windowsRead != currentPlaybackWindow) {
|
||||
synchronizeBufferWithPlayback();
|
||||
syncC++;
|
||||
} else {
|
||||
normC++;
|
||||
}
|
||||
syncPercentage = (syncC*100)/(float)(normC+syncC);
|
||||
System.out.printf("%.2f", syncPercentage);
|
||||
System.out.print("%\n");
|
||||
|
||||
//wait for a bit before reading again depending on the speed at which the system does playback.
|
||||
waitTime = Math.max(0, millisPerWindow - TimeUtils.timeSinceMillis(timeOfLastRead));
|
||||
try {
|
||||
@ -213,6 +209,7 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
public void start() {
|
||||
if (thread == null) {
|
||||
thread = new Thread(this, name);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
} else {
|
||||
synchronized (this) {
|
||||
|
@ -35,10 +35,11 @@ public class Page extends Group implements Disposable {
|
||||
|
||||
@Override
|
||||
public void setStage(Stage stage) {
|
||||
if (stage == null && !hasParent()) {
|
||||
if (stage == null) {
|
||||
if (!hasParent()) {
|
||||
dispose();
|
||||
}
|
||||
if (!(stage.getViewport() instanceof ScreenViewport)) {
|
||||
} else if (!(stage.getViewport() instanceof ScreenViewport)) {
|
||||
throw new IllegalArgumentException("Pages are explicitly for GUIs, and thus should have a 1:1 ratio between pixel and texture size for maximum clarity. This means that the stage should be using a ScreenViewport.");
|
||||
}
|
||||
super.setStage(stage);
|
||||
|
@ -149,6 +149,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
stage.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user