improve page unloading
This commit is contained in:
+7
-2
@@ -48,5 +48,10 @@ class Start {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch game
|
// Listen on history back
|
||||||
new Start().launch("canvas-container");
|
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) {
|
if (this.running) {
|
||||||
this.requestNextFrame();
|
this.requestNextFrame();
|
||||||
this.onLoop();
|
this.onLoop();
|
||||||
} else {
|
|
||||||
this.window.close();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -372,10 +370,14 @@ export default class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
if (this.currentScreen !== null) {
|
||||||
|
this.currentScreen.onClose();
|
||||||
|
}
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.worldRenderer.reset();
|
this.worldRenderer.reset();
|
||||||
this.itemRenderer.reset();
|
this.itemRenderer.reset();
|
||||||
this.screenRenderer.reset();
|
this.screenRenderer.reset();
|
||||||
|
this.window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
getThreeTexture(id) {
|
getThreeTexture(id) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default class ScreenRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
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