I have a separate class that needs to access the input data from the main loop. I was trying to use a pointer like I did for the render window but Input won't let me. Sorry I don't know much about pointers. Is reason that the constant is already a pointer and I need to convert it somehow?
My code is:
const sf::Input& Input = renderWindow.GetInput();
//*********************************************************
sf::Input &input = Input; //This same approach worked for
menu.setInput(&input); //pointing to the renderWindow
//**********************************************************
while(renderWindow.IsOpened()) {
// Process events
sf::Event Event;
while (renderWindow.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
renderWindow.Close();
}
// Fill the background black
renderWindow.Clear(sf::Color(0, 0, 0, 255));
//if menu is not done run the menu loop otherwise start the rest of the program
if(!menu.cleanMenu()){
bool bResult = lgcManager.Loop();
}else{
menu.loop();
}
// Display window contents on screen
renderWindow.Display();
}
Where I try to get it I have:
void MainMenu::setInput(sf::Input inp){
mpInput = inp;
}
The error I get is:
error C2440: 'initializing' : cannot convert from 'const sf::Input' to 'sf::Input &'
1> Conversion loses qualifiers
I need to know how to point to the input constant so I can get input in other classes.