Correct way to destroy *everything*

Post your help queries and engine programming questions here

Correct way to destroy *everything*

Postby beyondcode » Fri Dec 09, 2016 3:28 pm

In the game I'm building I have two distinct modes which have nothing whatsoever in common with each other as far as the engine is concerned.

When switching between modes, I'm trying to completely tear down everything in ige, all event handlers, all scenegraphs, everything and restart. Here's the code I've ended up with:

Code: Select all
   static start() {
        return new Promise((resolve, reject) => {
            ige.start(function (success) {
                if (success) {
                else {

    static stop() {
        try {
            delete ige.input._eventListeners;
        catch(ex) {


The problem with this is that it's not quite catching everything. Each time I restart, ige runs one extra game tick per animation frame (I used the chrome profiler to spot this). So it gets slower and slower with each switch... I haven't yet been able to pinpoint where this comes from but ige clearly is keeping some state between reloads.

My question is... is there a better way to do this that I've missed? Or maybe am I trying to restart things a little too much, and perhaps I should just be focusing on more of a soft reset, destroying the scene and the input event handlers manually?

Many thanks in advance, Pete
Posts: 1
Joined: Fri Dec 09, 2016 11:23 am

Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest