Game Development Community

Mouse cursor problems

by Richard Preziosi · in General Discussion · 04/16/2008 (5:07 pm) · 4 replies

After a few hours I could not resolve this myself nor has anyone else resolved it that i could find through my searches.

I've been able to successfully bind a right mouse look option in my game. However, I have not been able to bind a cursor toggle with this.

Example: hold the right mouse button to look around, release it to click different parts of the interface with the cursor.

The mission editor does exactly what I am trying to achieve. However if i put a show cursor in with my "freelook" function I can get the cursor to show, but can't get it to go away when i hold the right mouse button.

my basic code that works for the right click look that i came up with is:

moveMap.bind( mouse, button1, FreeLook);

function FreeLook(%val)
{
if (%val)
{
echo("pressed.......");
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
}
else
{
echo("released.....");
moveMap.bind( mouse, xaxis, "");
moveMap.bind( mouse, yaxis, "");
}
}


I've tried putting in cursoroff/on() canvas.setcursor() and things like that, but i just can't get it to work. Like i said i get the initial working, but as soon as i let go and the cursor comes up, i'm stuck. Any help is appreciated, thanks.

#1
04/19/2008 (8:39 pm)
Ok I was able to achieve what I want through 2 different functions, one using the right mouse button to look around and one using the m key to toggle the mouse. If I right mouse look it brings the cursor up when I let go, making it impossible to right mouse look again, but if i hold "m" i can then right mouse look, having to alter holding "m" and letting go lets me right mouse look. I'm going to post my code, but I cannot seem to combine the two codes to make just the right mouse button handle both. Every combination just makes the game freeze after the mission loads.

moveMap.bind( mouse, button1, FreeLook);
moveMap.bind( keyboard, m, toggleMouse);

function FreeLook(%val)
{
  if (%val)
  {
    echo("pressed.......");  
    cursorOff(); 
    moveMap.bind( mouse, xaxis, yaw );
    moveMap.bind( mouse, yaxis, pitch );
    
    
  }
  else
  {
    echo("released.....");
    moveMap.bind( mouse, xaxis, "");
    moveMap.bind( mouse, yaxis, "");
    CursorOn();
    
  }
}

function toggleMouse()
{   
   if
   (Canvas.isCursorOn())      
      CursorOff();   
   else      
      CursorOn();
}
#2
03/02/2009 (12:52 am)
I've been away for a while, and recently came back, but through searching I see that nobody has achieved this effect as of yet, or atleast that I could find. So I wanted to reopen this and see if anyone had any new ideas.

Thanks,
Tannayr
#3
03/02/2009 (1:24 am)
As per our IRC conversation, here is the solution to your problem:

www.garagegames.com/community/resources/view/16527