improve page unloading
This commit is contained in:
+7
-2
@@ -48,5 +48,10 @@ class Start {
|
||||
}
|
||||
}
|
||||
|
||||
// Launch game
|
||||
new Start().launch("canvas-container");
|
||||
// Listen on history back
|
||||
window.addEventListener('pageshow', function (event) {
|
||||
// Launch game
|
||||
if (!window.app || !window.app.running) {
|
||||
new Start().launch("canvas-container");
|
||||
}
|
||||
});
|
||||
@@ -127,8 +127,6 @@ export default class Minecraft {
|
||||
if (this.running) {
|
||||
this.requestNextFrame();
|
||||
this.onLoop();
|
||||
} else {
|
||||
this.window.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -372,10 +370,14 @@ export default class Minecraft {
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.currentScreen !== null) {
|
||||
this.currentScreen.onClose();
|
||||
}
|
||||
this.running = false;
|
||||
this.worldRenderer.reset();
|
||||
this.itemRenderer.reset();
|
||||
this.screenRenderer.reset();
|
||||
this.window.close();
|
||||
}
|
||||
|
||||
getThreeTexture(id) {
|
||||
|
||||
@@ -47,7 +47,7 @@ export default class ScreenRenderer {
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.stack2d.clearRect(0, 0, this.window.width, this.window.height);
|
||||
this.stack2d.clearRect(0, 0, this.window.canvas2d.width, this.window.canvas2d.height);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user