Compare orientation for mobiles devices?

Get help using Construct 2

Post » Thu Nov 08, 2012 6:28 am

Hey all, i need a help how to compare orientation, if is portrait mode, it should pause the game, otherwise if is landscape mode, it can continue the game.

Is for browser, not native mobile apps.


Thanks!.
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Thu Nov 08, 2012 7:59 am

ummm. well. A thought would be to do a "check on every X seconds" say 1. If your fortunate the window Width will change. Check all the Width of course just to make sure. If it changes then you have your check. I used this model in straight js, but i'm guessing here in C2.

oh oh. You should be able to check the acceleramotr instead of width. I'm not sure which vector your checking for or the degree's before the tablet instelf changes. but I think this will work out.jayderyu2012-11-08 08:01:24
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Nov 08, 2012 8:03 am

Use compare values, if windowwidth>windowheight it's landscape, else it's portrait.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Nov 08, 2012 8:30 am

I added an event: windowwidth>windowheight well it didn't work, in that case is using letterbox scale
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Thu Nov 08, 2012 6:36 pm

Hmm. Maybe it doesn't work on all devices. Maybe every tick try setting a text object to windowwidth and windowheight to see what the problem is?
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Fri Nov 09, 2012 7:55 am

B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Fri Nov 09, 2012 9:10 am

Oh, the reason it's not working is you're using letterbox scale. If you switch it to scale it works. That will require you to make your own black borders, though.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Fri Nov 09, 2012 9:21 am

[QUOTE=Arima] Oh, the reason it's not working is you're using letterbox scale. If you switch it to scale it works. That will require you to make your own black borders, though.[/QUOTE]

Yes, it worked if is scale.

However, is there a workaround for no fullscreen and letter box versions?
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Fri Nov 09, 2012 7:56 pm

Aside from checking the accelerometer, not that I know of.

Edit: I suppose you could do something like check if the windowwidth changes, if the new windowwidth is lower than the previous windowwidth, it's probably in portrait. Tough that wouldn't help for determining if it's in portrait or landscape at start, though.Arima2012-11-09 20:01:29
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests