Game Development Community

Hide / Show Cursor

by Austin Reynolds · in Torque Game Engine Advanced · 05/05/2008 (6:22 pm) · 6 replies

Hey all, (I also posted this in the TGE for the TGE engine) but for TGEA im also trying to figure out how to hide / show the cursor. I cannot find any post / resources that are up today(not more then 3 years old) on how to do this.

Basicly I want to try to make my cursor work "RPG" style. I have everything complete but the hiding / showing when the person right clicks the mouse.

Any help / tips would be nice even just a link to maybe a resource im not finding.

Thanks,
Austin Reynolds

#1
05/06/2008 (9:34 am)
The default scripts that come with the build have a couple of helpful functions:
cursorOn();
cursorOff();
I think you can guess what they're for. Also, make sure you check the top level object in your GUI (generally the GameTSCtrl) and ensure that noCursor = 0. That should give you complete control over when the cursor appears and doesn't appear.

I'll also throw out a warning right now that there are some problems with Torque and showing the Cursor. Essentially, many parts of the engine assume that when the Cursor is on that you are working with the GUI in some way and thus will not pass certain events down to your ActionMap, which handles all game-related inputs. If you have access to AFX I would direct you there to see what kind of changes you need to make to ensure mouse inputs get passed down to your ActionMap.
#2
05/06/2008 (10:33 am)
Does the AFX package come with how to make those fixes? If so it might just be worth me buying it. To use the code and learn a bit.

But ill also try what you have mentioned above real quick. in my playgui.cs I have chagned it to show cursor = 0 but have no luck in my bind.cs on making it display / not display.

When they right click if I want the cursor to hide I do put that in the bind.cs right? Noob question but just making sure.
#3
05/06/2008 (11:59 am)
Ok heres exactly what I got, in playGui.gui I have noCursor = "0"; and that makes the cursor visible

Then in my defualt.bind.cs file I have

function leftClick(%val)
{
cursorOn();
}
function rightClick(%val)
{

cursorOff();
}

moveMap.bind( mouse, button0, leftClick );
moveMap.bind( mouse, button1, rightClick );


But this code does not do anything. The cursor stays visible at all times. So I must be missing something, or just play doing something wrong.
#4
05/06/2008 (9:58 pm)
Ok got a little ahead of myself haha....

Yes it works, but like you said once the cursor is shown on the screen it no longer follows commands due to what im guessing is the gui. So now to figure that out.

I think after I get it all finished because I have all my cursor commands so its "RPG" style besides this last issue im going to right a resource sense there are none that I can find that is.

So im going to mess with that a bit guessing I will have to change some source code from what ive been reading.
#5
05/08/2008 (4:00 pm)
Alright update on my problem and maybe someone can shoot a tip or two....

I have got it so when the user right clicks and the gui is up it hides the cursor so they can control where they are looking except for one issue.

When they right click and the cursor is showing it hides the cursor. But then they have to right click again to control the mouse movement(due to how I have it setup)

Ill explain that real quick when the mouse is not visible if you right click it binds the following
moveMap.bind(mouse ,xaxis,yaw);
moveMap.bind(mouse, yaxis,pitch);
then when you let off the mouse it unbinds it so you stop controling the yaw and pitch.

So back to the issue. When they right click when cursor is visible it hides it then they have to right click again to control the ability to look around.

So im trying to find a way to do something like when they right click not only does it hide the cursor but registers in the script that they have the right mouse button down so they can look around.

Any help would be GREAT!

Thanks,
Austin
#6
02/21/2009 (8:43 pm)
Hi, did you get it to work? Im having the same problem.