Matter-js: How to stop, clear & destroy Matter.js instance?

Created on 29 Jan 2018  路  1Comment  路  Source: liabru/matter-js

Sorry for maybe stupid questions and for my bad English 馃

How to stop, clear & destroy Matter.js instance and debug renderer?

I create matter-js instance and debug renderer at runtime and I tried to destroy it by this way:


        Matter.Render.stop(this.debugRender); // this only stop renderer but not destroy canvas
        Matter.World.clear(this.engine.world);
        Matter.Engine.clear(this.engine);

Everything is working and looks like ok but is it right way?
And that about memory leaks and how properly to kill debug renderer including canvas.

question

Most helpful comment

Yeah this is the right way to reset, though you're right that it will not destroy anything from memory.

If you want to do that for the renderer, you should dereference the canvas fully:

render.canvas.remove();
render.canvas = null;
render.context = null;
render.textures = {};

>All comments

Yeah this is the right way to reset, though you're right that it will not destroy anything from memory.

If you want to do that for the renderer, you should dereference the canvas fully:

render.canvas.remove();
render.canvas = null;
render.context = null;
render.textures = {};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

253153 picture 253153  路  3Comments

ShadewEnder picture ShadewEnder  路  3Comments

koko236 picture koko236  路  3Comments

cluber22 picture cluber22  路  3Comments

drachehavoc picture drachehavoc  路  4Comments