Game Development Community

Checking button presses

by Jason Hardesty · in Torque X 2D · 11/27/2007 (9:11 am) · 1 replies

In the blaster tutorial in the FireProjectileComponent they map the A button like this

if (gamepadId >= 0)
{
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.A, MoveMapTypes.Button, 0);
}

I modified it to look like this:

if (gamepadId >= 0)
{
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftTrigger, MoveMapTypes.Button, 0);
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.RightTrigger, MoveMapTypes.Button, 0);
}

Now I want the left trigger to fire the same _fire() method that is in the tutorial and the right to fire my blast method. To fire the projectile they check if a button is pressed like this:

if (move != null && move.Buttons.Buttons[0].Pushed == true)
{
_Fire();
}

Does this just check if any button is pressed that is maped to the controller? I want to be able to check if the left or right triggers are pressed like this:

if(move != null && rightTrigger.pushed == true)
{
_Fire();
}

if(move != null && leftTrigger.pushed == true)
{
_blast();
}

I know the above code doesnt work but thats what I want to check if pushed.
Thanks
Jason

#1
11/27/2007 (11:51 am)
Nevermind I had the same moveIdx set for both the right ad left triggers.