Game Development Community

Move Cursor to Center of Screen?

by Damian S · in Torque 3D Professional · 05/28/2011 (1:10 pm) · 1 replies

I've set up the code so that on rightmouse down the cursor shows up and you can drag it. however, the cursor stays hidden at the point where i left it on right mouse up.

Is there a simple way to get the cursor to end up in the middle of the screen after rightmouseup()?



So far ive tried this:
*****************************
%centerpos = Canvas.getCenter();

Canvas.setCursorPos(%centerpos);
echo(%centerpos);

*****************************

aswell as replacing %centerpos with numerical values. The echo gives off the right numbers but the cursor does not return to those x/y coords.

Thanks

#1
05/28/2011 (5:29 pm)
The cursor position is actually in screen coordinates so the two coordinates system you have there (getCenter() is parent-relative) don't match up. To account for that, add the window coordinates (Canvas.getWindowPosition()) to your coordinates.