Game Development Community

Improving input control

by Toks · in Torque Game Engine · 06/21/2007 (7:12 am) · 2 replies

Hey everyone,

I could do with some help to get me started. I'm looking for a way to improve the input control, allowing me not only process the pressing of keys, but also the releasing. (so when a key was pressed, and you release it again it should call some function or something like that) (kind of like the onTriggerUp thing in statemachines i realize now). How should i tackle this?

thanks everyone

#1
06/21/2007 (7:18 am)
This is already available in Torque. Use the %val parameter to determine whether the key is pressed down or released. If %val is true, the key has been pressed down - it resets to false when the key is released.
function foo(%val)
{
   if(%val)
      echo("key pressed down");
   else
       echo("key released");
}
#2
06/21/2007 (7:48 am)
The mode Tim describes above is with the ActionMap.bind(...) mapping..if you want even more flexibility, the ActionMap.bindCmd(...) mode allows you to call one function on the key down (called the "make event"), and a different function on the key up (called the "break event")--although with this mode, no value is sent to either of the functions.