Game Development Community

Hiding the cursor using the mouse button

by Isaac Dutton · in Technical Issues · 04/04/2006 (11:25 am) · 4 replies

First off I am sorry if this is a noobish question, but I have searched a rather long time and could not find my answer, tried several diffrent things and still cant get it to work, thus I am posting here.

I am fairly certian that it will take some C++ coding into the engine to get this done, though I might end up benig wrong, let me explain what I already have and see if I am doing it right, or if there is something I am missing!

moveMap.bind( mouse, button1, mouseRight ); // button1 is the right mouse button

function mouseRight(%val)
{
   if(%val)
   {
      $mouseRightDown = true;
      CursorOff();

   }
   else
   {
      $mouseRightDown = false;
      CursorOn();

   }
}

First I will explain what I thought my code was suppose to do, firstly when I press the mouse button its suppose to show the cursor, and then when I release it its suppose to hide it. I thought this would work because when a function is mapped it is ran twice, once when the button is pressed and then once when it is released.

However this is not happening, If I start the game with the cursor showing this function dosnt even get called when the button is pressed, how ever after some testing, I have found if I start the mission with the cursor hidden, and then use a button to show it, and on release hide it, it shows but never hides.

I feel that when the cursor is shown the key maps go some where else or something, I am not really sure, how ever this system is already in place for things like the map maker, they show and hide the cursor the same way I am trying to do it. I have searched through the source and didnt really find anything, though my search was short and really not very presistant in that area.

If someone could please shine some light on this subject for me then I would be very greatfull as I am at a standstill as far as this goes!

#1
04/04/2006 (12:18 pm)
Try this:

GlobalActionMap.bind( mouse0, button1, mouseRight );

function mouseRight(%val){
  if(%val){
    if($cursorOn == true){
      $cursorOn = false;
      CursorOff();
    } else {
      $cursorOn = true;
      CursorOn();
    }
  }
}

Hope that helps. Note that the GlobalActionMap also means that if you RightClick anywhere in TGE, then it will call the function - not just when your playing. :)
Also, remove the 'if(%val){' and '}' to make it work OnUp and OnDown of the mouse, as you wanted it too.
#2
04/04/2006 (12:33 pm)
Thank you so much!!!
That worked great, I cant believe it was so easy, just a global I didnt know that!

Thank you again bro, that helped alot owe ya one big!
#3
04/04/2006 (12:45 pm)
Thank you so much!!!
That worked great, I cant believe it was so easy, just a global I didnt know that!

Thank you again bro, that helped alot owe ya one big!
#4
04/04/2006 (12:55 pm)
Glad I could help. :)

Tip: Don't use the refresh button if you have just posted. :P