Detect the width and height of userscreen resolution?

Get help using Construct 2

Post » Sat Aug 08, 2015 7:43 pm

How would one do this? I assume that there's no way to easily detect aspect ratio, am I right? Thanks, Morgan.
Image
B
20
S
4
Posts: 382
Reputation: 2,974

Post » Sun Aug 09, 2015 4:17 am

Assuming you are making your game fullscreen, then you can simply lookup the ViewportRight(0) and ViewportBottom(0) to determine the screen resolution. Then you can do some quick math to determine the screen ratio that the player is playing in.

width/height = pixel ratio

for example 1920x1080 = 1.78 = 16:9
B
87
S
44
G
16
Posts: 1,005
Reputation: 17,938

Post » Sun Aug 09, 2015 8:47 pm

@justifun - can you use an event to get these numbers? How would you look them up?
Image
B
20
S
4
Posts: 382
Reputation: 2,974

Post » Mon Aug 10, 2015 3:25 am

start a new project....
make a text box object

on start of layout - > set text1.text to "Height:" & ViewportBottom(0) & "Width:" & ViewportRight(0)

they are found in the system section when adding an action.

the (0) in each of them refer's to a specific layer you want lookup
B
87
S
44
G
16
Posts: 1,005
Reputation: 17,938

Post » Mon Aug 10, 2015 6:29 pm

@justifun - thanks!
Image
B
20
S
4
Posts: 382
Reputation: 2,974


Return to How do I....?

Who is online

Users browsing this forum: gskunk, tarek2 and 43 guests