Is there a way to lock orientation on mobile phone browsers?

0 favourites
  • 10 posts
From the Asset Store
This Student Workbook uses both Construct 3 & 2 encoding. It supplies client-side & php "back-end" encoding.
  • Is there a way to lock mobile phone orientations when testing c2 games on a phone browser? I know the browser ojbect has that option but it doesn't quite work out as it only freezes the game until your in the right orientation.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The project 'orientations' property is used in a mobile browser if the browser supports the Screen Orientation API. However this is not yet widely supported, and may only take effect after using 'Request fullscreen' as well. IIRC, Firefox for Android supports it, and it's being worked on for Chrome on Android.

  • I think there is no way that is 100% bullet proof yet, you could in theory make the game rotate if the window size you defined is a square but that would cause problem on PCs (except if your games works in both orientations thanks to this).

    Also I think you need the browser to go fullscreen to lock it with the action you described (or the project propriety).

    I think the widely accepted way is currently to ask the user to rotate his device in the case it isn't the good orientation, but that can be a problem on PCs too.

    EDIT:Ninja'd

  • You can adapt by creating a "rotate device" message. Create a Top layer for all layouts. Draw a large Black sprite and cover the entire layout. Place a "Rotate Device" message in the form of an image. Remember to set the parallax to 0,0 and the scale rate to 0 in the properties dialog for the layer. Use the browser object:

    Brower is Portrait > Layer Top > Set InVisible

    ___________________________________>Set time scale 0.0 (pauses the game)

    Brower is Landscape > Layer Top > Set Visible

    ___________________________________>Set time scale 1.0 (resumes game)

  • Ashley

    Aphrodite

    I appreciate the input guys. The 'Request fullscreen' was mentioned in the manual somewhere that not all browsers have this feature, so that's understandable.

    TheDom

    Yea I figured I would have to resort to this method. I appreciate the response. I thought I would have to use gamma,alpha or beta to pull up a message to get the right orientation, but it seems this method is much quicker and easier.

  • TheDom

    This is quite nice idea. However when i applied this method of your to game. It shows message on computer screens. I have to scale browser window from fullscreen to landscape ratio size too.

    Do you have any idea about solution?

  • Set the parallax to 0,0 .

  • Here's another way I've done it with a portrait game.

  • TheDom Many thanks!

  • You can adapt by creating a "rotate device" message. Create a Top layer for all layouts. Draw a large Black sprite and cover the entire layout. Place a "Rotate Device" message in the form of an image. Remember to set the parallax to 0,0 and the scale rate to 0 in the properties dialog for the layer. Use the browser object:

    Brower is Portrait > Layer Top > Set InVisible

    ___________________________________>Set time scale 0.0 (pauses the game)

    Brower is Landscape > Layer Top > Set Visible

    ___________________________________>Set time scale 1.0 (resumes game)

    Great Info Thanks..

    but noticed small issue with the code shown. Should read

    Brower is Portrait > Layer Top > Set Visible

    ___________________________________>Set time scale 0.0 (pauses the game)

    Brower is Landscape > Layer Top > Set InVisible

    ___________________________________>Set time scale 1.0 (resumes game)

    unless you want the other way then it would read

    Brower is Portrait > Layer Top > Set InVisible

    ___________________________________>Set time scale 1.0 (resumes game)

    Brower is Landscape > Layer Top > Set Visible

    ___________________________________>Set time scale 0.0 (pauses the game)

    But great information on how to get desired device layout. Thanks again Jeremy C.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)