Game Development Community

GUI and TX2D Coordinates

by Tony Pitman · in Torque X 2D · 07/04/2009 (6:40 pm) · 3 replies

From what I understand in a TX2D game the center of the screen is 0,0 and the corners are (if my size is 100 and height is 75) -50, -37 - 50, -37, etc.

From what I can tell of the GUI stuff, however, they start 0,0 at the upper left corner and go for the screen size.

Are there any utility functions available to quickly convert from one to the other?

#1
07/05/2009 (7:10 am)
Hey Tony,

I've been using the the function in this thread to convert world units to GUI units. I don't have one for the other way around, but would be interested to know what you come up with.
#2
07/05/2009 (12:54 pm)
If you plan on only using one resolution, you can change the camera position and size to match the screen resolution, i.e. for 1024x768 camera extent is the same and CenterPosition is (512,384); then everything is done using the same coords. I've done that sometimes for GUI stuff and its pretty simple.

Then, when you set position of an object, it is in in screen space, speed units are pixels/second, etc.
#3
07/06/2009 (6:08 am)
Thank you for the replies. I did write my own function to convert. In my game the camera is still so it is pretty simple.

I was hoping there was a built in helper function or something for performance reasons, but if there isn't, so be it.

Thanks again....