How do I detect scaled layout coordinates?

Get help using Construct 2

Post » Sat Apr 26, 2014 10:45 pm

I have something set to when TouchStartX < 960 (because the layout is set to 1920 x 1080) but when it's displayed on a lower res display, even when TouchStartX is greater than halfway across the screen horizontally it still triggers because it's counting the actual resolution of the display. For example, if the display was 1280 x 720, the condition should trigger when X<640 on the actual display. But the problem is that the layout coordinates don't scale even though the layout itself scales everything in it. How do I either make layout coordinates scale or detect the display resolution?
B
5
S
1
Posts: 31
Reputation: 439

Post » Sun Apr 27, 2014 11:13 am

Whan you make something scaleable, you cannot use exact numbers anymore.

You should always use relative positions. Best way to do is keeping numbers in variables. like gameWidth, gameHeight. You have to re assign this variables everytime screen changes.

and ur conditions will be like this, "when TouchStartX < gameWidth/2"
Truth shall be your freedom...
B
14
S
2
G
1
Posts: 45
Reputation: 930

Post » Wed Apr 30, 2014 12:11 am

And how do you get the current gameWidth? Everything I've tried only gives me the pre-scaled coordinates.
B
5
S
1
Posts: 31
Reputation: 439

Post » Wed Apr 30, 2014 12:39 am

You can use "WindowWidth" and "WindowHeight" both are system variables, that you can find in System.

Image
Image
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu May 01, 2014 9:21 am

@nimos100 is saying it right @Zygorithm however, you "have to" reduce all possible calculations due the performance issues when you are making a html based game.

using browser objects "onresized" event and assigning width and height on variables is better then forcing browser to re calculate the with and height each time you need them. specially on loops.
Truth shall be your freedom...
B
14
S
2
G
1
Posts: 45
Reputation: 930


Return to How do I....?

Who is online

Users browsing this forum: ratboy3 and 42 guests