Game Development Community

Push Button callback in GUI sticking

by Morgan Lean · in Torque Game Engine · 05/22/2005 (12:57 am) · 2 replies

Hi all.

In the starter FPS pack, I've created a push button "Fire" which when pressed fires the crossbow. The mode is in third person view with cursorOn() called to get the mouse cursor to display.

What I find happening is that the fire command is repeated over and over again like the button is stuck down. But the echo event is only displayed once. To stop the firing, I have to press the button again.

In playGui.cs, the callback from the button is Canvas.getContent().onButtonFire(); as below.

function PlayGui::onButtonFire(%this)
{
$mvTriggerCount0++;
//mouseFire();
echo("Fire!");
}

Tried either $mvTriggerCount0++ and mouseFire() and either doesn't fix the problem. It like the trigger counter keeps on increasing even though the button is released (its defined as a Push Button in the GUI).

Is there anyway to stop this? This function seems to be only called once when I press the button (the echo confirms this) but its like something else has taken control and making that variable keep on increasing.

#1
05/22/2005 (3:54 pm)
You have to increment the variable again if you want the firing to stop. I suggest using a schedule() call to leave it "on" for just a moment, then turn it off again.
#2
05/23/2005 (3:21 am)
Thanks, that worked.