Game Development Community

Query: How to hover the mouse

by Arthur Ogawa · in Torque Developer Network · 01/08/2007 (1:17 pm) · 2 replies

I understand from studying the Whak-a-mole tutorial how to let the user click on an object, but I would like to accomplish something a bit snazzier: the hover. I know there must be a function for this in TGB, because the Level Builder window's Create tab has such a function for the objects in the Scrollers rollout: when you hover the cursor over a scroller, it plays. The hover is also present for objects in other rollouts.

So, I would like to add such a feature to my game. Imagine Whack-a-mole, where the mole's appearance changes when you hover the hammer over it: it would begin to perspire or show evidence of anxiety.

Any hints on where to get started with this function? Thanks for your attention.

(My apologies for cross-posting this query; I had originally put it in the forum GarageGames Site Feedback/Feedback)

#1
01/08/2007 (6:26 pm)
OnMouseMove should tell you when the mouse moves onto an object. Finding when it moves off is a bit trickier.

One way is to have a variable for which object the mouse is currently on. Then, every time onMouseMove is called, restart a timer. If the timer goes for long enough without being reset (1/4 second, say) then you know the mouse has moved off the object. Also, if a different object recieves onMouseMove you know the mouse is off the previous object.
#2
01/08/2007 (8:41 pm)
Thanks for your post, Joseph!