Kartou Posted January 11, 2016 Share Posted January 11, 2016 Hi! I'm having trouble with destroying the game after use. I'm calling game.destroy(), but this does not properly shut down the core game loop, hence crashing in:c.Game.updatec.RequestAnimationFrame.updateRAFwindow.requestAnimationFrame.forceSetTimeOut._onLoopwith the error:Uncaught TypeError: Cannot read property 'slowMotion' of nullFrom the source code it looks like game.destroy() should cancel all further updates etc. Maybe I'm missing something? Link to comment Share on other sites More sharing options...
Kartou Posted January 13, 2016 Author Share Posted January 13, 2016 I have created an example in the sandbox that displays the error. Please see error in the console after pressing the left arrow: http://phaser.io/sandbox/edit/mqmaJDwh It looks like the destroy does not properly stop the requestAnimationFrame. Maybe I'm not supposed to call game.destroy() at that time? c.Game.updateLogic @ phaser.js:34680 c.Game.update @ phaser.js:34619 c.RequestAnimationFrame.updateRAF @ phaser.js:58258 window.requestAnimationFrame.forceSetTimeOut._onLoop @ phaser.js:58242 Link to comment Share on other sites More sharing options...
Henryk Posted February 28, 2017 Share Posted February 28, 2017 I have exactly the same problem. Did you find a way to solve it? Link to comment Share on other sites More sharing options...
samme Posted February 28, 2017 Share Posted February 28, 2017 On 1/13/2016 at 7:22 AM, Kartou said: It looks like the destroy does not properly stop the requestAnimationFrame. Maybe I'm not supposed to call game.destroy() at that time? `destroy` has done its job; the problem is that you're still in the middle of `updateLogic`, which can't continue because `game.stage` and other references are now missing. Try calling `destroy` from a keypress handler instead. Link to comment Share on other sites More sharing options...
Henryk Posted February 28, 2017 Share Posted February 28, 2017 Samme! Thanx a lot for this hint. I realized that the updateLogic was still running. But I had no clue how to stop or break through it. I thought maybe I have to delete a reference to something or I don't know. But I spent 2 days now looking for a solution. Restructuring code. Finding work arounds etc. And in the End it works by just using a simple (button) click event. This should definitely be more obvious or explained somewhere. It's crucial, isn't it? Thanks again. So glad. Link to comment Share on other sites More sharing options...
Recommended Posts