Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Cameleon

Pages: [1]
1
Window / Handling input in a state based approach
« on: December 02, 2010, 08:19:09 pm »
Hi. I'm writing a puzzle game using SFML2 for windowing and input, however my game's main loop looks like this

Code: [Select]

//at init
this->input = window->GetInput(); //oinoput of type const sf::Input&

 while(//running) //while the current state is still running
{
   stateManager->stateLoop(input);
   this->window->Display();
}


Code: [Select]

stateManager::stateLoop(sf::Input& input)
{
   //check various state flags
   currentState->HandleInput(input); //<-Need access to sf::Input& here
}


I'm unsure how to hand down input handling to each state. I have tried passing an instance of sf::Input by reference down through the state manager to the state but I was getting compiler errors about the class being non copyable. Any help would be great

Pages: [1]
anything