Game Development Community

Toggle Cursor

by Nancy Lee · in Technical Issues · 12/02/2008 (3:47 am) · 1 replies

Hi, i have been trying to get it work but couldnt...

I tried to add the following code in the default.bind.cs in client

function ToggleCursor(%val)
{
if(%val)
{
if( Canvas.isCursorOn() )
CursorOff();
else
CursorOn();
}
moveMap.bind( keyboard, m, ToggleCursor);


there is no change from my game at all.

Another problem is I have created dynamic field "noCursor = 1" in the PlayGui, now i can't even delete the dynamic field.

Could you please help me to make it work, I am frustrated about it.....

#1
12/02/2008 (5:37 am)
What kind of toggle are you trying to acheive? Do you want the cursor to disappear and re-appear alternately with each pressing of the bound key?

Each press of the bound key toggles the state of the cursor:
function toggleCursor()
{
  if(Canvas.isCursorOn())
    Canvas.cursorOff();
  else
    Canvas.cursorOn();
}

The cursor toggles off when key pressed and returns when key is release:
function toggleCursor(%val)
{
  if(%val)
    Canvas.cursorOff();
  else
    Canvas.cursorOn();
}

Make sure that your key binding is being defined before the actionmap is pushed.