Fade in on mouse move, fade out on mouse stop
by jerry smith · in Torque Game Builder · 09/28/2009 (3:05 pm) · 3 replies
I'm testing the tgb demo to see if it'll suit my needs. My normal coding language is actionscript (for flash), so I can navigate code a bit, but I haven't been able to achieve what I need. Simply, I need several objects to become visible as the mouse is moving, and when the mouse stops moving they need to fade out. All the objects need to fade in/out at different rates. I've been over the tutorials, have poked around the various fade behaviors and searched the forums. Any help would be appreciated.
#2
09/28/2009 (5:33 pm)
Thanks for the response Nate. I think it got me thinking in the right direction. Could I bother you to elaborate on a method for detecting when the mouse has stopped moving?
#3
09/28/2009 (6:11 pm)
There isn't one built into the engine as far as I know. There are callbacks for mouse clicks, mouse movement, mouse dragging and the mouse entering an area but none for it NOT moving. That's why I have the timer in the puedso code that resets the mouse to a not moving state. The idea is if the user is moving the mouse, he'll keep the MouseMoving flag set to true overwriting the timer as it ticks but once he stops the timer will set the mouse moving flag back to false. You can play around with the frequency of the timer if you get false positives.
Nate Gertsch
MainWindow::OnAdd(%fhis) { %this.setTimerOn(500); } MainWindow::OnMouseMove(%This) { $IsMouseMoving = true; } MainWindow::OnUpdate(%this) { if($IsMouseMoving) if(!$EveryThingFadedIn) FadeEverythingIn(); else return; else FadeEverythingOut() } MainWindow::OnTimerTick() { $IsMouseMoving = false; }