Game Development Community

Question about cursors

by Ehab Yosry Amer · in Technical Issues · 01/28/2010 (7:03 am) · 2 replies

(I'm posting this again here from the general discussion forum)

There is something that I'm having a hard time to understand, I know that to change the shape of the mouse cursor "Canvas.setCursor(THECUSOR)" does the trick, but for some reason its not working, nothing happens

& there is something else, some game-samples dont allow the mouse to escape from the window boundaries, I dont know how to do that, what I'm guessing is that my game is not rendering a mouse & is taking the mouse events from the windows mouse ..... or something like that.

I hope some1 out there would help me understand the how the mouse cursors work on torque.

I tried typing canvas.cursoron/off show/hide cursor in the console, but I'm still missing something.

basically I need to prevent the mouse from escaping the boundaries of the window, how can i do that?

thanks in advance

#1
01/28/2010 (8:40 am)
Basically, there's two different cursor systems in there. The one provided by the platform and the one implemented by Torque.

Platform cursors are not constrained to the window and are basically controlled entirely by the system. They are usually rendered in hardware and are quick and responsive. Downside is that there currently is no support there for using a custom bitmap on the cursor.

Torque cursors are rendered using Torque's own rendering system. They are a little less responsive but allow setting custom cursors. They are also constrained to Torque's window.

Platform cursors are active when the mouse is *not* locked whereas Torque cursors are active when the mouse *is* locked (though usually, they are hidden).

IIRC, to lock the mouse and show the cursor, you need to set $cursorControlled=false and call showCursor().

Unfortunately, the two system's tend to fight each other a little since each time the mouse is unlocked, the platform cursor takes over again. For your game, you basically want to ensure the mouse stays locked to your window.
#2
01/28/2010 (9:59 am)
thanks for the quick reply.

thanks for the detailed explanation, thats pretty much how I pictured it but failed to pinpoint how it is exactly.

what I noticed when I tried it now:
$cursorControlled=false is "common/gamescripts/cursor.cs" in the show/hide cursor functions.
According to what u explained the call "lockMouse(false/true);" is what switches between using the platform mouse or the torque mouse, & that got what I needed working and my problem solved :)