morosenerd Posted January 14, 2015 Share Posted January 14, 2015 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 More sharing options...
rich Posted January 14, 2015 Share Posted January 14, 2015 How are you testing? (if you say "Chrome device emulation" the problem is right there) morosenerd 1 Link to comment Share on other sites More sharing options...
morosenerd Posted January 14, 2015 Author Share Posted January 14, 2015 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 More sharing options...
rich Posted January 16, 2015 Share Posted January 16, 2015 Yeah it's annoying but the screen orientation API in Chrome isn't part of the emulation! So Phaser gets well confused. It thinks you're using a mobile re: screen space, but the orientation is read from your PCs monitor. Very annoying. Link to comment Share on other sites More sharing options...
Henryk Posted January 29, 2015 Share Posted January 29, 2015 So, does this mean, I cannot emulate it anymore in Chrome?Why was it working before?Can I downgrade Chrome or something? Link to comment Share on other sites More sharing options...
Recommended Posts