Ok, I have on Master class called CAsteroidsApp. It keeps references (not pointers) to other important classes such as CInputManager and CStateManager, here's the code I'm using for this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
namespace Asteroids
{
class CAsteroidsApp : public Application::CApplication, public Input::CInputMap
{
public:
//...
private:
//...
State::CStateManager & m_StateManager;
Input::CInputManager & m_InputManager;
Input::CKeyboardManager & m_KeyboardManager;
Input::CMouseManager & m_MouseManager;
sf::RenderWindow & m_RenderWindow;
};
}
| |
They are initialised at the .cpp file as it follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
namespace Asteroids
{
CAsteroidsApp::CAsteroidsApp()
:
m_StateManager(Singleton<State::CStateManager>::GetInstance()),
m_KeyboardManager(Singleton<Input::CKeyboardManager>::GetInstance()),
m_MouseManager(Singleton<Input::CMouseManager>::GetInstance()),
m_InputManager(Singleton<Input::CInputManager>::GetInstance()),
m_RenderWindow(Singleton<sf::RenderWindow>::GetInstance())
{
//...
}
//...
}
| |
After some thinking, I decided that the CKeyboardManager and the CMouseManager, being directly related to input, should be integrated into the CInputManager class, so I did this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
namespace Input
{
//...
class CInputManager
{
public:
//...
private:
CKeyboardManager & m_KeyboardManager;
CMouseManager & m_MouseManager;
//...
};
}
| |
And I initialised these new references exactly how I did in CAsteroidsApp:
1 2 3 4 5 6 7 8 9 10 11
|
namespace Input
{
CInputManager::CInputManager()
:
m_KeyboardManager(Singleton<CKeyboardManager>::GetInstance())
m_MouseManager(Singleton<CMouseManager>::GetInstance())
{
//...
}
//...
}
| |
And now my entire game stopped running. The console shows up and hangs there, doing absolutely nothing. I know these modifications are the problem because I undid all them (leaving CMouseManager and CKeyboardManager references again in CAsteroidsApp) and the game ran fine.
What is causing this and what can I do to fix it?
Best Regards,
~Deimos