Game Development Community

TGB onMouseEnter onMouseLeave problem

by Bruno Campolo · in Torque Game Builder · 09/02/2010 (8:24 pm) · 2 replies

Sorry for the double post, but I accidentally posted this in the wrong forums and may be why I didn't receive any replies:

I implemented the following:

function myObject::onMouseEnter(%this, %modifier, %worldPos)
{
Canvas.setCursor(CrossHairCursor);
}

function myObject::onMouseLeave(%this, %modifier, %worldPos)
{
Canvas.setCursor(DefaultCursor);
}

which works... with one major flaw. The cursor only changes WHEN YOU MOVE THE MOUSE, yet 'myObject' (which is also moving) can move under the mouse and away from the mouse without triggering this event and therefore not changing the cursor.

The funny thing is if I echo anything to the console it will check for this event and trigger it if necessary. I would just hate to have to write garbage to the console every 1/10 of a second to make this work correctly.

Any advice?

About the author

Creator of Bantam City Games, a one-man independent game development studio. To learn more, check out 'A Game Developer's Saga', a game development blog at: http://www.bantamcity.com/blog


#1
09/02/2010 (8:41 pm)
Looking at the source code, it's very obvious that "onMouseEnter" and "onMouseLeave" will only be called when the mouse moves.

An easy option is to use t2dSceneGraph's pickPoint functionality either in an "onUpdate" function or on a schedule (every 50 milliseconds or so).
#2
09/02/2010 (8:47 pm)
Thanks William. I was thinking something like that, but didn't know if someone had already come across the same thing and had an easy fix/work-around. If I don't hear anything like that, I'll give what you suggested a try.