Show/HideCursor shenanigans
by David Roberts · in Torque Game Builder · 07/25/2006 (4:26 pm) · 9 replies
Hi all,
After what seems like ages away I have dove back into T2D and started reaquainting myself with the new tutorials. All seems good so far but I have noticed something strange happening after finishing the WhackAMole tutorial.
Once in game, as soon as you move the mouse, the cursor reappears over the hammer - despite the call to Canvas.hideCursor() in the game.cs script. By placing this call in moleLevel.cs like so....
... it seems to solve the problem and the game functions as expected.
If you load up the exampleWhackAMole project and run the game, the same problem occurs once you move the mouse.
Just wondering as a sanity check if this is expected behaviour, a bug, or aliens have invaded my hard drive and started messing with my Torque scripts!
Cheers in advance,
Dave
After what seems like ages away I have dove back into T2D and started reaquainting myself with the new tutorials. All seems good so far but I have noticed something strange happening after finishing the WhackAMole tutorial.
Once in game, as soon as you move the mouse, the cursor reappears over the hammer - despite the call to Canvas.hideCursor() in the game.cs script. By placing this call in moleLevel.cs like so....
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
moleHammer.setPosition(%worldPosition);
// Added this little line here....
Canvas.hideCursor()
}... it seems to solve the problem and the game functions as expected.
If you load up the exampleWhackAMole project and run the game, the same problem occurs once you move the mouse.
Just wondering as a sanity check if this is expected behaviour, a bug, or aliens have invaded my hard drive and started messing with my Torque scripts!
Cheers in advance,
Dave
About the author
#2
If you don't add the line Canvas.hideCursor() in that function (which I added - it wasn't in the tutorial code) - the cursor reappears when you move the mouse for the first time.
However, I would have imagined that once you have made the call to hideCursor, it shouldn't reappear until you call showCursor at some point - which in the tutorial, happens at the end of the game. That is why I'm wondering whether something strange might be going on.... :-)
07/25/2006 (4:47 pm)
Well, I believe that the cursor shouldn't be overlaid on top of the hammer graphic. If you don't add the line Canvas.hideCursor() in that function (which I added - it wasn't in the tutorial code) - the cursor reappears when you move the mouse for the first time.
However, I would have imagined that once you have made the call to hideCursor, it shouldn't reappear until you call showCursor at some point - which in the tutorial, happens at the end of the game. That is why I'm wondering whether something strange might be going on.... :-)
#3
At least you learned something from the tutorial. lol. ;D
07/25/2006 (5:09 pm)
Hmmm, I'm at a loss.At least you learned something from the tutorial. lol. ;D
#4
07/26/2006 (9:58 am)
I don't know if it makes a difference but you forgot a semi colon at the end of Canvas.hideCursor()
#5
07/27/2006 (2:15 am)
Heh, only in copying into the quote - its in my code, honest. :-)
#6
www.garagegames.com/mg/forums/result.thread.php?qt=46967
07/27/2006 (9:25 am)
I think this might help.www.garagegames.com/mg/forums/result.thread.php?qt=46967
#7
Plus now I know about the Canvas.cursorOff/cursorOn function - always a bonus! :-)
07/28/2006 (3:51 am)
Yep, that defo helps - cheers.Plus now I know about the Canvas.cursorOff/cursorOn function - always a bonus! :-)
#8
07/28/2006 (4:13 am)
You can also just use a transparent / invisible cursor rather than repeatedly calling hideCursor() inside onMouseMove. Ref: www.garagegames.com/mg/forums/result.thread.php?qt=47448
#9
Double bonus!
Now I've got a long afternoon at work before I can get back to Torquing....
07/28/2006 (4:26 am)
Excellent, I've been thinking about how to change the cursor graphic as well! Double bonus!
Now I've got a long afternoon at work before I can get back to Torquing....
Torque Owner Kevin James
I got too bored of the tutorials so I never did the WhackAMole one. By the code above, it seems that the mole hammer would go to wherever the mouse is, then the cursor would disappear.