Key bind Question
by JD Scogin · in Torque Game Builder · 09/03/2007 (9:45 am) · 2 replies
Is there a way to tell if a key is still pressed?
Here is the code:
$myup ... is a variable so I can changed the keys)
When a key is pressed, my player moves a certain distance.
I need to be able to check to see if the key is still pressed so he can keep moving or stop.
Having trouble finding how to do this.
I am sure it is in the docs, but I just can't seem to find it.
Thanks
Jd
Here is the code:
moveMap.bindObj(getWord($myUp, 0), getWord($myUp, 1), "moveUp", %this); moveMap.bindObj(getWord($myDown, 0), getWord($myDown, 1), "moveDown", %this); moveMap.bindObj(getWord($myLeft, 0), getWord($myLeft, 1), "moveLeft", %this); moveMap.bindObj(getWord($myRight, 0), getWord($myRight, 1), "moveRight", %this);
$myup ... is a variable so I can changed the keys)
When a key is pressed, my player moves a certain distance.
I need to be able to check to see if the key is still pressed so he can keep moving or stop.
Having trouble finding how to do this.
I am sure it is in the docs, but I just can't seem to find it.
Thanks
Jd
About the author
#2
Yea, I think you are correct.
I just need to set a variable to know when it is up or down.
Thanks
09/03/2007 (12:48 pm)
Bingo!Yea, I think you are correct.
I just need to set a variable to know when it is up or down.
Thanks
Torque Owner Spider
Also, if you use bindCmd, you can specify a keydown function and a keyup function.
In my opinion, bindCmd is way better because the functions are actually 'eval'ed so you have way more flexibility.
Sorry my answer is so unsure... don't have the docs right in front of me.