bool ActorStateMachine::onEvent(const Event& e) { // forward event upstream if it is going upstream if (currentState && e.getSender() == currentState) { // give specific implementation a chance to handle it. if (onPreUpstreamEvent(e)) { return true; } else { return distributeEvent(e); } } // otherwise forward downstream else if (currentState) { // give specific implementation a chance to handle it. if (onPreDownstreamEvent(e)) { return true; } else { return currentState->onEvent(e); } } // not handled because no current state else { return false; } }
bool MainMenuScene::onEvent(const Event& e) { return distributeEvent(e); }