diff --git a/examples/destroy/index.html b/examples/destroy/index.html
index f3e48ca2..7c6167ae 100644
--- a/examples/destroy/index.html
+++ b/examples/destroy/index.html
@@ -79,6 +79,7 @@
document.addEventListener("keydown", (e) => {
+ // spacebar
if (e.keyCode === 32) {
if (app) {
app.destroy();
diff --git a/src/tree/Stage.mjs b/src/tree/Stage.mjs
index 7925ffc5..656f58f5 100644
--- a/src/tree/Stage.mjs
+++ b/src/tree/Stage.mjs
@@ -132,7 +132,7 @@ export default class Stage extends EventEmitter {
try {
return !!window.WebGLRenderingContext;
- } catch(e) {
+ } catch (e) {
return false;
}
}
@@ -180,7 +180,7 @@ export default class Stage extends EventEmitter {
opt('memoryPressure', 24e6);
opt('bufferMemory', 2e6);
opt('textRenderIssueMargin', 0);
- opt('fontSharp',{precision:0.6666666667, fontSize: 24})
+ opt('fontSharp', { precision: 0.6666666667, fontSize: 24 })
opt('clearColor', [0, 0, 0, 0]);
opt('defaultFontFace', 'sans-serif');
opt('fixedDt', 0);
@@ -224,6 +224,16 @@ export default class Stage extends EventEmitter {
this.textureManager.destroy();
this._renderer.destroy();
+ // clear last rendered frame
+ if (this.gl) {
+ this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
+ this.gl.clear(this.gl.COLOR_BUFFER_BIT);
+ } else if (this.c2d) {
+ this.c2d.clearRect(
+ 0, 0, this.c2d.canvas.width, this.c2d.canvas.height
+ );
+ }
+
this.gl = null;
this.c2d = null;
this.ctx = null;
@@ -510,10 +520,10 @@ export default class Stage extends EventEmitter {
}
}
- getChildrenByPosition(x, y){
+ getChildrenByPosition(x, y) {
const children = [];
this.root.core.update();
- this.root.core.collectAtCoord(x,y,children);
+ this.root.core.collectAtCoord(x, y, children);
return children;
}