Modify onFire with keyboard Input
by Jeremy Alessi · in Torque Game Engine · 08/15/2005 (9:27 pm) · 0 replies
I want to get a different result from my onFire functions with the mouse if you hit the mouse for example and W is being held I want one result and if some other key is held I want yet another.
I found some code here:
http://www.garagegames.com/mg/forums/result.thread.php?qt=5985
Robert Blanchet Jr. posted something in that thread above which seemed useful by creating a new action map.
I've done this:
Unfortunately, the bigSwing function is never getting called.
I found some code here:
http://www.garagegames.com/mg/forums/result.thread.php?qt=5985
Robert Blanchet Jr. posted something in that thread above which seemed useful by creating a new action map.
I've done this:
%hitType = 0;
// Create some flags
$bigSwingFlag = false;
// Pop off all other existing action maps
if( isObject(moveMap) )
moveMap.pop();
if( isObject(InventoryMap) )
InventoryMap.delete();
// others ... ?
// Declare new action map for our gui control
new ActionMap(InventoryMap);
// Setup the keys
InventoryMap.bind(keyboard, "w", bigSwing);
// Push the action map
InventoryMap.push();
// default hand to hand weapon code
%hitType = checkBinding();
WeaponImage::onFireHandToHand(%this, %obj, %slot, %hitType);
%obj.setEnergyLevel(100);
moveMap.push();
return;
}
// <- phdana hth
function bigSwing(%val)
{
echo("Big Swing Function");
if(%val)
$bigSwingFlag = true;
else
$bigSwingFlag = false;
}
function checkBinding()
{
echo("Check Binding");
%hitType = 2;
if($bigSwingFlag)
%hitType = 0;
return %hitType;
}Unfortunately, the bigSwing function is never getting called.
About the author