Game Development Community

Check if mouse button is being released?

by Maddermadcat · in Torque Game Engine · 12/29/2007 (8:24 am) · 3 replies

What I noticed is that the function bound to a mouse button is called both on press and release. This has been quite helpful but also problematic, and I was wondering if there was any way to check if the mouse button is being released in script.

Any help will be appreciated. =)

#1
12/30/2007 (1:40 pm)
I would just set a flag when you enter the function. If the flag is already set when you enter, you know this current event is the mouse release, and you can clear it.
#2
12/30/2007 (3:40 pm)
moveMap.bind(mouse, "button0", moveleft );

function moveleft(%val)
{
   //...
}

In the above script the moveleft() function is bound to a mouse button. The paramter passed %val will be 1 or True if the button is pressed and 0 or false on release.

Alternatively you can use the bindCmd() function which takes a parameter to specify each event:
moveMap.bindCmd(keyboard, "escape", "buttonDnFunc();", "buttonUpFunc();");

Gabriel
#3
01/16/2009 (3:00 am)
@Gabriel. That is incorrect for mouse functions. That's why when you click the mouse button it fires only once. It will have to be implemented.