So I'm following the SFML Game Dev book and I've learned the basic of C++. But I don't know what it's doing with the constructor really. Specifically, the mWindow and mPlayer right after the constructor. Why can't those be called in the constructor, why is it outside? It works and all but I would like to know why it works and what is it.
Game::Game()
: mWindow(sf::VideoMode(630, 380), "SFML") //What is this and the line below it?
, mPlayer()
{
player.setRadius(40.f);
player.setPosition(100.f, 100.f);
player.setFillColor(sf::Color::Blue);
}
Why doesn't this work?
Game::Game()
{
mWindow(sf::VideoMode(630, 380), "SFML");
mPlayer();
player.setRadius(40.f);
player.setPosition(100.f, 100.f);
player.setFillColor(sf::Color::Blue);
}