SFML community forums
Help => Window => Topic started by: WillYoung on March 22, 2011, 10:50:25 pm
-
Hello everybody!
I want to get the input from the window and the documentation tells me to do this:
const sf::Input& Input = App.GetInput();
Which is fine and dandy, it works as expected but I have my project situated in classes. The 'App' window is in a class and I want to have sf::Input within the class also.
The problem is I don't know how to put this into the class and use it in one of the class's functions due to it being a Const and requiring it to get the pointer from App.GetInput(); which I would need to call once the App has been initialized.
Am I missing something fundamental here?
Thanks in advance.
Will,[/code]
-
const sf::Input& is a reference, therefore it must be initialized in the constructor's initializer list.
class MyClass
{
public:
MyClass()
: app(sf::VideoMode(800, 600), "Title")
, input(app.GetInput())
{
}
private:
sf::RenderWindow app;
const sf::Input& input;
};
-
You Sir require Kudos. Thank you for the quick reply and it has done the job spectacularly, it was something trivial after all!
Will,