Jump to content

enterIncorrectOrientation no longer works in 2.2?


morosenerd
 Share

Recommended Posts

Hey!

 

After upgrading from a previous version (2.0.something) to 2.2.2 I noticed that my orientation handling code (lifted directly from the Full Screen Mobile template) no longer works. This is my Boot.js:

BasicGame = {    /* Your game can check BasicGame.orientated in internal loops to know if it should pause or not */    orientated: false};BasicGame.Boot = function (game) {};BasicGame.Boot.prototype = {    create: function () {        this.input.maxPointers = 1;        this.stage.disableVisibilityChange = true;        this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;        // this.scale.minWidth = 480;        // this.scale.minHeight = 260;        // this.scale.maxWidth = 1024;        // this.scale.maxHeight = 768;        // this.scale.pageAlignHorizontally = true;        // this.scale.pageAlignVertically = true;        this.scale.forceOrientation(true, false);        //this.scale.hasResized.add(this.gameResized, this);        this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);        this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);        // this.scale.setScreenSize(true);        this.state.start('Preloader');    },    enterIncorrectOrientation: function () {        BasicGame.orientated = false;        document.getElementById('orientation').style.display = 'block';    },    leaveIncorrectOrientation: function () {        BasicGame.orientated = true;        document.getElementById('orientation').style.display = 'none';    }};

With 2.0.x phaser.js lib, the above code displays my "please rotate device" image when the orientation changes to portrait. After swapping for 2.2.2 phaser.js, it doesn't work. The functions "enterIncorrectOrientation" and "leaveIncorrectOrientation" never actually run (I tested it with console.log), so I guess either the Signals are not added or Phaser doesn't detect orientation anymore. API change? What should I try instead?

 

I guess I could use .setResizeCallback instead, then add a test for example if window.innerWidth < window.innerHeight then display the orientation image, so there's that. But I'd prefer to use a built-in Phaser's method if possible.

Link to comment
Share on other sites

Yes, thanks. I was too quick to post. I use device emulation all the time to see if my responsive layout works in various setups.

 

BTW, big thanks for scale mode RESIZE! It allowed me to drop several blocks of hackish resize code and still get the same effect!

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

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