Jump to content

A Real Orientation Fix


Recommended Posts

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');


Link to comment
Share on other sites

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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