Jump to content

Game stops working in portrait mode on mobile


Biggerplay
 Share

Recommended Posts

I've created a game with Phaser, and it works completely fine except for one strange problem, and that's on mobile when the device is oriented to portrait, the game stops working, if you try to load the game when in portrait mode you just see the preloading screen and the loading bar but it doesn't load, rotating the screen around allows it to load, but if you rotate it back to portrait it again stops working and nothing happens when you tap the screen, it's like the game becomes paused.

 

How can I make it so that either it works in both portrait and landscape, or show some kind of msg so people know to rotate the screen to landscape?

 

I'm using these settings in the boot.js file

 this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;		    this.game.stage.scale.minWidth = 480;		    this.game.stage.scale.minHeight = 260;		    this.game.stage.scale.maxWidth = 1024;		    this.game.stage.scale.maxHeight = 768;		    this.game.stage.scale.forceLandscape = true;		    this.game.stage.scale.pageAlignHorizontally = true;		    this.game.stage.scale.setScreenSize(true);
Link to comment
Share on other sites

look \resources\Project Templates\Full Screen Mobile example :) it works fine.

Just noticed this in boot.js of the full screen mobile example

this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;            this.game.stage.scale.minWidth = 480;            this.game.stage.scale.minHeight = 260;            this.game.stage.scale.maxWidth = 1024;            this.game.stage.scale.maxHeight = 768;            this.game.stage.scale.pageAlignHorizontally = true;            this.game.stage.scale.pageAlignVertically = true;            this.game.stage.scale.forceOrientation(true, false);            this.game.stage.scale.hasResized.add(this.gameResized, this);            this.game.stage.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);            this.game.stage.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);            this.game.stage.scale.setScreenSize(true);

Is that just for 1.1.4? or is that only for 1.1.5? and if it's 1.1.5 how do I upgrade to using that?

 

*Edit*

 

I've just implemented the new code in the boot.js example file and now my game's not working at all, just a black screen, so does that mean that above code is for 1.1.5?

Link to comment
Share on other sites

The black screen issue has gone, but I've still got original issue, which is when the game is portrait mode it seems paused? how can I have it so that it runs fine in both modes (landscape and portrait) or it that's not possible have it so that a msg appears telling people to rotate the screen to landscape?

 

Ok I found if I remove this line

 

this.game.stage.scale.forceOrientation(true, false);

 

Then the game doesn't pause anymore in portrait mode, but now the game screen is bigger than the browser window! 

 

*EDIT*

 

I've fixed the problem, but I don't know how hacky it is or not, basically I did this

 

this.game.stage.scale.forceOrientation(true, true);

 

And that allows it work fine in portrait and landscape, but if that's not doing it right, I'll be happy to know the correct solution. (just leaving that line out means the game screen overlaps the browser window which is not what I need).

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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