Game Development Community

CLOSE

by Tim Tebow · in Torque Game Engine · 05/03/2008 (9:17 pm) · 16 replies

---

#1
05/03/2008 (9:27 pm)
I'm not 100% on how to do what you're asking, may I ask why you are wanting to hide the mouse button on right click? May help to get your problem resolved faster. You can start with this base code though.
function toggleMouse(%val)
{   
   if 
   (%val, Canvas.isCursorOn())      
      CursorOff();   
   else      
      CursorOn();
}

movemap.bind(mouse, button1, togglemouse);

That "should" get you on the right track, you may or may not need the "%val" in the if statement, you may not need either of the "%val". I never know when to exactly use those.
#2
05/03/2008 (10:18 pm)
-
#3
05/03/2008 (11:04 pm)
Ok that's what I thought you were wanting to do, back when i wanted to do this it was like verions 1.4 and it wasn't really possible without modifying the engine code. I'm not at a position to try it right now, but you could try this code.

//moveMap.bind( mouse, xaxis, yaw );
//moveMap.bind( mouse, yaxis, pitch );
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, "");
  }
}

you might need to delete any other references to xaxis and yaxis anywhere in your bind.cs. Then this might not even work without altering the source code.
#4
05/04/2008 (6:41 pm)
Going to try that right now, ill update how it goes.
#5
05/04/2008 (6:55 pm)
The second post that has the code box worked good. Some minor adjustments to get it perfect but someone should be able to take this code and make it work for them.
#6
05/04/2008 (6:56 pm)
Works in TGEA also
#7
05/04/2008 (6:57 pm)
-
#8
05/04/2008 (10:49 pm)
My first example should be what you want, you'd just have to throw "cursorOn()" or "cursorOff()" into your function or command or whatever you are wanting to turn the cursor off/on.
#9
05/04/2008 (11:36 pm)
Here is my exact code, and for some reason does not toggle the cursor on or off. Dont say anything in the ~ prompt either.

// Mouse Trigger
//------------------------------------------------------------------------------
function toggleMouse(%val)
{
if
(%val, Canvas.isCursorOn())
CursorOff();
else
CursorOn();
}

moveMap.bind(mouse, "button0", toggleMouse);
#10
05/04/2008 (11:37 pm)
Also i tried it with and without the "" around button0
#11
05/05/2008 (12:39 pm)
-
#12
05/05/2008 (5:39 pm)
Did you make sure there was no other reference to button0 in the default.bind.cs? Also I dont' think you need the "%val" for that, no clue why, only say that cause this code toggles the mouse for me. I think i made an oopsy in the first post when i put the %val.

function toggleMouse()
{   
   if
   (Canvas.isCursorOn())      
      CursorOff();   
   else      
      CursorOn();
#13
05/05/2008 (6:10 pm)
Im going to copy paste what you have but no the only thing I have for bind for mouse is what I posted above. You didnt make any engine code chagnes did you?

Going to try this and let you know how it goes
#14
05/05/2008 (6:15 pm)

-
#15
05/06/2008 (5:28 pm)
Try setting it up to a key first, say "m" or something not currently being used and see if you can get it to show up. Then try setting your "nocursor=" in your playgui to a different setting, I didn't make any engine codes at all. Also you may wanna back up your default.bind.cs and copy over the one from tutorial.base and start fresh, maybe something got changed around, added, or deleted by accident in yours.

I do remember when i attempted to implement the system you are in version 1.3 I had a heck of a time getting TGE to regain control of the mouse after I did any toggle control with a mouse button push.
#16
05/06/2008 (9:40 pm)
-