Game Development Reference
In-Depth Information
2.
A virtual analogue stick supports two directions and is determined by its radius,
mask color, and position:
struct sBitmapAxis
{
float FRadius;
vec2 FPosition;
int FAxis1, FAxis2;
vec4 Fcolour;
};
3.
The ScreenJoystick class contains descriptions for all of the buttons and axes:
class ScreenJoystick
{
std::vector<sBitmapButton> FButtonDesc;
std::vector<sBitmapAxis> FAxisDesc;
4.
The values for each axis and the Pressed lags for each button are stored in two
arrays:
std::vector<float> FAxisValue;
std::vector<bool> FKeyValue;
5.
The mask bitmap data pointer is also necessary for this class:
unsigned char* FMaskBitmap;
6.
The FPushed* arrays tell us which buttons and axes are currently activated:
sBitmapButton* FPushedButtons[MAX_TOUCH_CONTACTS];
sBitmapAxis* FPushedAxis[MAX_TOUCH_CONTACTS];
7.
The constructor and destructor are essentially empty:
ScreenJoystick(): FMaskBitmap( NULL ) {}
virtual ~ScreenJoystick() {}
8.
The InitKeys() method allocates the state arrays when the joystick construction
is inished:
void InitKeys()
{
FKeyValue.resize( FButtonDesc.size() );
if ( FKeyValue.size() > 0 )
{
for (size_t j = 0 ; j < FKeyValue.size() ; j++ )
FKeyValue[j] = false;
}
FAxisValue.resize( FAxisDesc.size() * 2 );
if ( FAxisValue.size() > 0 )
 
Search WWH ::




Custom Search