How do I detect scaled layout coordinates?

0 favourites
  • 5 posts
  • 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?

  • 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"

  • And how do you get the current gameWidth? Everything I've tried only gives me the pre-scaled coordinates.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use "WindowWidth" and "WindowHeight" both are system variables, that you can find in System.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)