Beispiel #1
0
	void MainMenuState::HandleInput() {
		sf::Event event;

		while (this->_data->window.pollEvent(event)) {
			if (sf::Event::Closed == event.type) {
				this->_data->window.close();
			}

			if (this->_data->input.IsSpriteClicked(this->_playButton, sf::Mouse::Left, this->_data->window)) {
				//std::cout << "Go To Game Screen" << std::endl;
				this->_data->machine.AddState(StateRef(new GameState(_data)), true);
			}
		}
	}
Beispiel #2
0
	void PauseState::HandleInput() {
		sf::Event event;

		while (this->_data->window.pollEvent(event)) {
			if (sf::Event::Closed == event.type) {
				this->_data->window.close();
			}

			if (this->_data->input.IsSpriteClicked(this->_resumeButton, sf::Mouse::Left, this->_data->window)) {
				//std::cout << "Go To Game Screen" << std::endl;
				//remove current state to continue the game
				this->_data->machine.RemoveState();
			}

			if (this->_data->input.IsSpriteClicked(this->_homeButton, sf::Mouse::Left, this->_data->window)) {
				//remove pause state then replace gameState with MainMenuState
				this->_data->machine.RemoveState();

				this->_data->machine.AddState(StateRef(new MainMenuState(_data)), true);
			}
		}
	}
StateRef State::create( Context* context ){
    return StateRef( new State(context) );
}