Reset multitouch buttons state when game is restarted
This commit is contained in:
parent
65363a2fa0
commit
184ecce836
@ -43,14 +43,7 @@ MultitouchDevice::MultitouchDevice()
|
||||
assert(m_android_device != NULL);
|
||||
#endif
|
||||
|
||||
for (MultitouchEvent& event : m_events)
|
||||
{
|
||||
event.id = 0;
|
||||
event.touched = false;
|
||||
event.x = 0;
|
||||
event.y = 0;
|
||||
}
|
||||
|
||||
reset();
|
||||
updateConfigParams();
|
||||
} // MultitouchDevice
|
||||
|
||||
@ -183,6 +176,28 @@ void MultitouchDevice::clearButtons()
|
||||
m_buttons.clear();
|
||||
} // clearButtons
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets all buttons and events to default state
|
||||
*/
|
||||
void MultitouchDevice::reset()
|
||||
{
|
||||
for (MultitouchButton* button : m_buttons)
|
||||
{
|
||||
button->pressed = false;
|
||||
button->event_id = 0;
|
||||
button->axis_x = 0.0f;
|
||||
button->axis_y = 0.0f;
|
||||
}
|
||||
|
||||
for (MultitouchEvent& event : m_events)
|
||||
{
|
||||
event.id = 0;
|
||||
event.touched = false;
|
||||
event.x = 0;
|
||||
event.y = 0;
|
||||
}
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** The function that is executed when touch event occurs. It updates the
|
||||
* buttons state when it's needed.
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
void addButton(MultitouchButtonType type, int x, int y, int width,
|
||||
int height);
|
||||
void clearButtons();
|
||||
void reset();
|
||||
|
||||
/** Returns the number of created buttons */
|
||||
unsigned int getButtonsCount() {return m_buttons.size();}
|
||||
|
@ -154,6 +154,11 @@ void RaceGUIBase::reset()
|
||||
m_plunger_speed = core::vector2df(0,0);
|
||||
m_plunger_state = PLUNGER_STATE_INIT;
|
||||
clearAllMessages();
|
||||
|
||||
if (m_multitouch_gui != NULL)
|
||||
{
|
||||
m_multitouch_gui->reset();
|
||||
}
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -76,6 +76,18 @@ RaceGUIMultitouch::~RaceGUIMultitouch()
|
||||
} // ~RaceGUIMultitouch
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the multitouch race gui to its initial state
|
||||
*/
|
||||
void RaceGUIMultitouch::reset()
|
||||
{
|
||||
if (m_device != NULL)
|
||||
{
|
||||
m_device->reset();
|
||||
}
|
||||
} // reset
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Clears all previously created buttons in the multitouch device
|
||||
*/
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
unsigned int getMinimapBottom() {return m_minimap_bottom;}
|
||||
void setGuiAction(bool enabled = true) {m_gui_action = enabled;}
|
||||
void reset();
|
||||
|
||||
}; // RaceGUIMultitouch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user