Game Development Community

Determining window size

by Bruce Morick · in Torque 2D Beginner · 09/02/2015 (4:44 pm) · 2 replies

Is there a Torque 2D function to determine the physical window size like "x0, y0 , xe, ye =win32ui.FindWindow(None,winName).GetWindowRect()[0:4]" that is cross platform (i.e. Windows and Android)? I would like to know the size of the display in which the game is playing in. I have searched but I can not find anything.

#1
09/02/2015 (9:55 pm)
From script:

%extent = Canvas.extent; // %extent is a string with "Width Height" (space separated) in it.

Torquescript doesn't support multiple return values - so your requested format is not supported, but as you can see it returns a string with space-separated values. If you need the actual game window location when playing in windowed mode, that's probably a lot trickier.

Also, notice that I used "Canvas" (with a capital C) because there is one global canvas object that is the entire game render surface and that's its name. So, in full screen mode this will tell you the resolution of the game (not necessarily the display - you could be running full screen 1024x768 when your display is capable of higher resolutions).
#2
09/02/2015 (11:11 pm)
Thanks Richard.

Now back to blowing myself up with grenades... LOL