Checking for key down?
by Jonathan Kelly · in Torque Game Engine · 01/17/2005 (3:58 pm) · 3 replies
Hello, I'm working on controls again.
With our game we have it if you hold a button down you go into 'sneak' mode, and when you let go of it you go back to idle. The only problem is that I can only toggle it on or off. Is there a check for a keydown or something like that?
With our game we have it if you hold a button down you go into 'sneak' mode, and when you let go of it you go back to idle. The only problem is that I can only toggle it on or off. Is there a check for a keydown or something like that?
#2
in the default.bind.cs.....
$fpsstate = 0;
function fps()
{
if ($fpsstate == 0)
{
metrics(fps);
metrics("video");
glenablemetrics(1);
$fpsstate = 1;
}
else if ($fpsstate == 1)
{
metrics();
$fpsstate = 0;
}
}
GlobalActionMap.bind(keyboard, "f", fps);
03/25/2005 (11:52 am)
This is my lame ass attempt to toggle frames per second counter on and off. As it turns out, it acts just like what you're looking for. Now, if you can tell me how to make one key toggle fps on and off, I'd appreciate it.in the default.bind.cs.....
$fpsstate = 0;
function fps()
{
if ($fpsstate == 0)
{
metrics(fps);
metrics("video");
glenablemetrics(1);
$fpsstate = 1;
}
else if ($fpsstate == 1)
{
metrics();
$fpsstate = 0;
}
}
GlobalActionMap.bind(keyboard, "f", fps);
#3
03/25/2005 (12:40 pm)
The reason you are getting unexpected behaviour is due to the way the bind calls its related functions. The function is called both when the key is PRESSED and then again when it is RELEASED. There is a value passed to the function, 1 if the key is down and 0 if it is up.
Associate Kyle Carter