Game Development Reference
In-Depth Information
if ((*thisIt)->VGetEventType() == inType)
{
eventQueue.erase(thisIt);
success = true;
if (!allOfType)
break;
}
}
}
return success;
}
The VAbortEvent() method is a simple case of looking in the active queue for the
event of a given type and erasing it. Note that this method can erase the first event in
the queue of a given type or all events of a given type, depending on the value of the
second parameter. You could use this method to remove redundant messages from
the queue, such as two
events for the same object.
All those queued messages have to be processed sometime. Somewhere in the game
move object
'
s
'
main loop, the Event Manager
s VUpdate() method should be called, and the
queued messages will get distributed like so many pieces of mail.
bool EventManager::VTickVUpdate(unsigned long maxMillis)
{
unsigned long currMs = GetTickCount();
unsigned long maxMs = ((maxMillis == IEventManager::kINFINITE) ?
(IEventManager::kINFINITE) :
(currMs + maxMillis));
// swap active queues and clear the new queue after the swap
int queueToProcess = m_activeQueue;
m_activeQueue = (m_activeQueue + 1) % EVENTMANAGER_NUM_QUEUES;
m_queues[m_activeQueue].clear();
// Process the queue
while (!m_queues[queueToProcess].empty())
{
// pop the front of the queue
IEventDataPtr pEvent = m_queues[queueToProcess].front();
m_queues[queueToProcess].pop_front();
const EventType& eventType = pEvent->VGetEventType();
// find all the delegate functions registered for this event
Search WWH ::




Custom Search