Game Development Community

Toggle Mouse On and Off

by Matt Huston · in Torque Game Engine · 10/04/2007 (2:09 am) · 1 replies

Does anyone have any code for turning your mouse on and off, I am working on a game that requires the player to use both FPS mode and then also use the mouse to select a GUI objects on the screen.

The following code does not work.

function toggleMouse(%val)
{
   if(PlayGui.noCursor)
      PlayGui.noCursor = false;
   else
      PlayGui.noCursor = true;      
}

moveMap.bind( keyboard, m, toggleMouse);

#1
10/04/2007 (5:26 am)
You were close, use this instead:
function toggleMouse()
{
   if(Canvas.isCursorOn())
      CursorOff();
   else
      CursorOn();
}