When handling keypresses, there are a couple of ways to interpret the event.
Previously, in Beyond Virtual, we only had the 'params.floatValue;' method of seeing whether a key has been pressed.
A few releases ago, we also added bool & int values for keypress events, which allow you to get a bit more specific info about whether a key has been pressed or not.
So you can do something like:
bool action= false;
bool HandleEvent( Object@ object, const String& in event, GameEventParams@ params)
{
if (event == "Input")
{
if (params.stringValue == "BoolAction")
{
action= params.boolValue; // true if the key has been pressed and not handled previously
return true;
}
}
}
Or, alternately, you can use the intValue to check and see whether a key has been pressed, released or hasn't changed state, like so:
bool action= false;
bool HandleEvent( Object@ object, const String& in event, GameEventParams@ params)
{
if (event == "Input")
{
if (params.stringValue == "IntAction")
{
if (params.intValue == 1)
{
// intValue value of 1 means that the key has been pressed (ie a KeyDown event)
action1= true;
}
if (params.intValue == -1)
{
// intValue of -1 means that the key has been released (ie a KeyUp event)
action= false;
return true;
}
}
}
}
So depending upon what you are looking to do you can use any of the floatValue, intValue or boolValue input events to handle specific keys.