Game Development Community

MousePosition

by Andrei Georgescu · in Torque Game Builder · 08/01/2010 (8:06 pm) · 3 replies

Hello! When I try to set the position of a GUI panel by my mouse position+50 it doesn't really work like I do expect to. It depends on resolution. Why?

I am using something like this:

tabTalentsDesc.setPosition(getWord(sceneWindow2D.getMousePosition(),0)*8+530, 180);

I am multiplying it by 8 because that's the only way it works on 800 x 600 resolution. I don't know the reason. Can someone give me a hint here please? Thanks!

#1
08/01/2010 (9:15 pm)
As I remember it, t2dSceneWindow's getMousePosition() will return the world/scene coordinates if there is an attached scene.

You can convert the scene coordinate back into a window coordinate by using t2dSceneWindow's getWindowPoint.

%worldMouseCoord = sceneWindow2D.getMousePosition();
%windowMouseCoord = sceneWindow2D.getWindowPoint( %worldMouseCoord );
tabTalentsDesc.setPosition( getWord( %windowMouseCoord, 0 ) + 50, 180 );

Warning: I did not actually try that code, but I'm certain it will work.
#2
08/01/2010 (9:28 pm)
Working. Thanks a lot mate!
#3
08/02/2010 (1:52 am)
Cool! Great to hear!