Jump to content

Phaser window and document scale event listeners problem...


freke1981SWE
 Share

Recommended Posts

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

  • 1 month later...

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 page

window.location.reload(true);

No trouble.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...