Lock orientation on Mobile browsers

Get help using Construct 2

Post » Wed May 10, 2017 1:23 pm

Hi everyone,

A client asks me for an HTML5 game which will be played mostly on mobile, and the game needs to be locked horizontally.
I referred to this tutorial by Ashley, in which I learned that screen locking only happens after requesting fullscreen, and fullscreen is potentially not supported on every browser.

So I made a test, and fullscreen mode is working fine on desktops, but not in a single mobile browser.
I tried the following browsers:
iOS Safari
iOS Chrome
Android Browser
Android Chrome (on 2 different devices)
and the fullscreen mode is never recognized on mobile devices. Which is a big problem for me... :( Is there any workaround which would allow me to lock orientation? Or maybe did I do something wrong?

On the link above I see that most browsers are notes as "partially supported". Do I need to do something special to access that feature?

On the code standpoint, I defined the Orientation as "Landscape" in the project settings, and am requesting the fullscreen on the title screen, on a "Touch" trigger event.

If you want to test the game, here is the WIP: http://test.smurf.com/drop18/
Oh and it needs to be an HTML5 game playable in a browser, no export with cordova.

Thanks for your help!
B
23
S
5
G
1
Posts: 335
Reputation: 2,406

Post » Mon May 15, 2017 9:04 pm

When youre building the APKs there's a setting for Orientation. In Cocoon for example in the Settings it shows the orientation. Intel XDX should have the same thing (I'd recommend Cocoon cause intels being tards and not supporting building apks anymore.

In Cocoon under Settings there is Orientation:
That lets you set the orientation. Make sure you change in both Default and the system(s) you're building apks and files for.
B
20
S
7
G
3
Posts: 302
Reputation: 3,634

Post » Tue May 16, 2017 9:20 am

Rable wrote:Oh and it needs to be an HTML5 game playable in a browser, no export with cordova.

Thanks for the reply, but I don't want to make an APK. The game should be playable fullscreen and horizontally in a browser. :/
B
23
S
5
G
1
Posts: 335
Reputation: 2,406

Post » Tue May 16, 2017 5:06 pm

Rable wrote:
Rable wrote:Oh and it needs to be an HTML5 game playable in a browser, no export with cordova.

Thanks for the reply, but I don't want to make an APK. The game should be playable fullscreen and horizontally in a browser. :/


In Construct 2 whats your configuration setting? My Fullscreen in Browswer is set to Letterbox Scale and Orientations is Landscape. Letterbox Scale and Landscape are working for me.
B
20
S
7
G
3
Posts: 302
Reputation: 3,634

Post » Wed May 17, 2017 2:54 pm

Both are working for me too, as well as fullscreen mode, as long as I am on desktop.
On mobile / tablet I can't have the fullscreen to work. If you try the link I gave in the first post, are you able to play in fullscreen on both desktop and mobile?
I personally don't. :(
B
23
S
5
G
1
Posts: 335
Reputation: 2,406

Post » Wed May 17, 2017 6:45 pm

@Rable

Could you compare the WindowHeight and WindowWidth and Set layout angle accordingly?

Something like:
WindowHeight > WindowWidth
Trigger once while true

Set layout angle to 90


WindowWidth > WindowHeight
Trigger once while true

Set layout angle to 0

EDIT: Or use the Browser Is Portrait/Landscape condition instead of comparing WindowWidth and WindowHeight
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
32
S
9
G
7
Posts: 444
Reputation: 6,731

Post » Thu May 18, 2017 10:50 am

@OddConfection
That's a clever idea!
I tried it (with browser orientation), and the result is sadly not what we would expect. The layout indeed rotate 90 degrees, but the window doesn't change size and doesn't rotate (I'm in letterbox scale fullscreen mode). So basically if you're holding your phone in portrait, you've got a small horizontal window in the middle , with the layout inside it rotated 90 degrees. You see a part of the rotated layout in the middle and large white borders on the left and right of the small window.
B
23
S
5
G
1
Posts: 335
Reputation: 2,406


Return to How do I....?

Who is online

Users browsing this forum: Davlin and 6 guests