jjwallace Posted April 28, 2016 Share Posted April 28, 2016 I am trying to prevent my game from starting unless in landscape. I looked at a couple methods but none of them seemed to work. The problem is my game renders all objects and sizes them when it starts. I want to wait for the correct orientation but that takes a second from the variable being set and the actual dimensions changing. Is there a better way to do this? update: function () { if (this.cache.isSoundDecoded('sfxPredator') && this.ready == false){ this.ready = true; console.log('Preload Complete'); } if(IApp.platform == 'tablet-l' || IApp.platform == 'phone-l' || IApp.platform == 'desktop'){ BGame.onLandscape = true; } if(BGame.onLandscape == true && this.ready == true && BGame.onCanStart == true){ console.log('Timer Start'); BGame.onCanStart = false; this.time.events.add(Phaser.Timer.SECOND * 0.3, this.startRenderGame, this); } console.log('Game Started'); this.state.start('Game'); }, Link to comment Share on other sites More sharing options...
mattstyles Posted April 29, 2016 Share Posted April 29, 2016 Add an event listener on to the resize event and only run your initialisation code when the orientation matches whatever you want. You'd probably want to show something during that time, and you'd also have to handle dimension changes during the lifetime of your app as well. Oh, and you can't stop an orientation change from the web either. Link to comment Share on other sites More sharing options...
jjwallace Posted May 2, 2016 Author Share Posted May 2, 2016 Ok this is what i did but i didn't user the resize listener. This makes sense since i think it registers the landscape faster than the actual screen changes. I will move this function to the resize listener. Link to comment Share on other sites More sharing options...
jjwallace Posted May 4, 2016 Author Share Posted May 4, 2016 Ok so i have tried over 9 different methods here. What happends is some how the width and height are original pulled in via portaite mode and then when landscape occurs it still falls back to the original centerX and centerY from orientation change? Link to comment Share on other sites More sharing options...
Recommended Posts