freke1981SWE Posted June 19, 2014 Share Posted June 19, 2014 Hello! I´m building a Angular single page web application, on one of the screens I have a Phaser game, after the game is finished the player comes to an Angular result screen. The problem is that these event listeners is still attached, see at the bottom. And I can´t figure out how to remove them due to the anonymous functions in them. So if I scale the app on the result screen the events are trigged but the game instance is destroyed. One solution is to edit the Phaser source, but I want to avoid that, any idéas? Events added by Phaser: window.addEventListener('orientationchange', function (event) { return _this.checkOrientation(event); }, false); window.addEventListener('resize', function (event) { return _this.checkResize(event); }, false); document.addEventListener('webkitfullscreenchange', function (event) { return _this.fullScreenChange(event); }, false); document.addEventListener('mozfullscreenchange', function (event) { return _this.fullScreenChange(event); }, false); document.addEventListener('fullscreenchange', function (event) { return _this.fullScreenChange(event); }, false); Link to comment Share on other sites More sharing options...
freke1981SWE Posted June 24, 2014 Author Share Posted June 24, 2014 I´ve solved this, by editing the source...so now all global events are removed when needed. Link to comment Share on other sites More sharing options...
eguneys Posted August 6, 2014 Share Posted August 6, 2014 Do you have a reliable plugin solution for this without editing the source but adding some plugin code maybe? And do you think this is the only problem there is to destroying Phaser. Maybe proper way is to use frames? Edit: I've found the best way is to simply refresh the page instead of a route. window.location.href = location;or reload the pagewindow.location.reload(true);No trouble. Link to comment Share on other sites More sharing options...
Recommended Posts