Game Development Community

Finding the center of the window

by Caleb · in Technical Issues · 04/22/2007 (4:32 pm) · 1 replies

Hello again. I was wondering if anybody knows how to find the center of the window. I want to be able to reset the cursor to the center. I could manually find what looks like the center, and then just tell the mouse to always go there, but what about when the player changes from full screen to small screen?

So all I need is a fairly accurate way a find the middle of the window so I can use "setCursorPos" to reset the cursor.

Thanks!

#1
04/22/2007 (4:48 pm)
He He....

Found the answer.
function centerCursor()
{
   %x = getWord(0, $pref::Video::resolution) / 2;
   %y = getWord(1, $pref::Video::resolution) / 2;

   Canvas.setCursorPos(%x, %y);
}
Thanks anyway.