Game Development Reference
In-Depth Information
{
memset( &FAxisValue[0], 0, FAxisValue.size() *
sizeof( float ) );
}
Restart();
}
9.
The Restart() method clears the state of pushed buttons:
void Restart()
{
memset( &FPushedAxis[0], 0, sizeof(sBitmapAxis*) *
MAX_TOUCH_CONTACTS );
memset( &FPushedButtons[0], 0, sizeof(sBitmapButton*) *
MAX_TOUCH_CONTACTS );
}
10. The internal state is changed by the private SetAxisValue() and SetKeyState()
methods:
void SetKeyState( int KeyIdx, bool Pressed )
{
if ( KeyIdx < 0 || KeyIdx >= ( int )FKeyValue.size() )
{ return; }
FKeyValue[KeyIdx] = Pressed;
}
void SetAxisValue( int AxisIdx, float Val )
{
if ( ( AxisIdx < 0 ) ||
AxisIdx >= (int)FAxisValue.size() )
{ return; }
FAxisValue[AxisIdx] = Val;
}
11. The IsPressed() and GetAxisValue() methods can read the state of a key
or an axis:
bool IsPressed( int KeyIdx ) const
{
return ( KeyIdx < 0 ||
KeyIdx >= ( int )FKeyValue.size() ) ?
false : FKeyValue[KeyIdx];
}
float GetAxisValue( int AxisIdx ) const
{
return ( ( AxisIdx < 0 ) ||
AxisIdx >= ( int )FAxisValue.size() ) ?
0.0f : FAxisValue[AxisIdx];
}
 
Search WWH ::




Custom Search