Jump to content

Any best practices for Screen Orientation


Aer
 Share

Recommended Posts

I've seen that here are some solutions for pausing the game after a screen orientation change event, but I wanted to know if anyone has solutions for locking / preventing the change. Also, preferably using only Pixi.js (I've seen Phaser has an option for handling, but not locking).

 

If it's not possible guess I'm just looking for best practices on handling this.

 

Thanks for helping this newb. :lol:

Link to comment
Share on other sites

  • 2 weeks later...

I do it like this:

 

First I decide if I want my game to be on portrait or landscape. Let's say I want to force landscape.

The first child of my stage is a DisplayObjectContainer.

All children are added to that DOC instead of the stage.

Now I observe the device orientation. If the device is not in landscape, I will simply resize the renderer view (switching height and width of the stage) and rotate that DOC by 90deg, also adjusting the DOC position.

 

Now it's still landscape on portrait.

The next step is to do the same with interactivity. You have to recalculate the mouse position because the top is now x and the left is now y.

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