void GameOverState::setCallbacks(const std::vector<Callback>& callbacks) { for (int i = 0; i < m_gameObjects.size(); i++) { if (dynamic_cast<MenuButton*>(m_gameObjects[i])) { MenuButton* pButton = dynamic_cast<MenuButton*>(m_gameObjects[i]); pButton->setCallback(callbacks[pButton->getCallbackID()]); } } }
void PlayState::setCallbacks() { for (int i = 0; i < m_gObjects.size(); i++) { if (dynamic_cast<MenuButton*>(m_gObjects[i])) { MenuButton* pButton = dynamic_cast<MenuButton*>(m_gObjects[i]); pButton->setCallbacks(m_callbacksID[pButton->getCallbackID()]); } } }
void MenuState::setCallbacks(const std::vector<Callback>&callbacks){ // go through the game objects for (int i = 0; i < m_gameObjectsMenuState.size(); i++) { // if they are of type MenuButton then assign a callback based on the id passed in from the file if (dynamic_cast<MenuButton*>(m_gameObjectsMenuState[i])) { MenuButton* pButton = dynamic_cast<MenuButton*>(m_gameObjectsMenuState[i]); pButton->setCallback(callbacks[pButton->getCallbackID()]); } } }