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

Get help using Construct 2

Post » Mon Apr 07, 2014 2:46 pm

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.
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Mon Apr 07, 2014 3:23 pm

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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,746

Post » Mon Apr 07, 2014 3:27 pm

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Apr 07, 2014 3:28 pm

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)
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Mon Apr 07, 2014 6:42 pm

@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.
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Mon Jun 23, 2014 9:59 pm

@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?
B
21
S
4
G
4
Posts: 161
Reputation: 3,803

Post » Mon Jun 23, 2014 10:36 pm

Set the parallax to 0,0 .
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Mon Jun 23, 2014 10:48 pm

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

Image
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Sat May 07, 2016 5:12 am

@TheDom Many thanks! :)
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

Post » Wed Jul 20, 2016 10:54 pm

TheDom wrote: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.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317


Return to How do I....?

Who is online

Users browsing this forum: dop2000, namaewayukidesu and 6 guests