Not quite sure how this works, i only have such a huge knowledge in c++ (Just kidding, constantly studying).
But i created a class, withing the class i did this:
class Game
{
private:
sf::RectangleShape rectangle;
sf::CircleShape circle;
sf::Text text;
public:
Game(sf::Vector2f size, sf::Vector2f position, sf::Color color)
{
rectangle.setSize(size);
rectangle.setPosition(position);
rectangle.setFillColor(color);
}
Game(float radius, sf::Vector2f position, sf::Color color)
{
circle.setRadius(radius);
circle.setPosition(position);
circle.setFillColor(color);
}
Game(/*sf::Font loadFont ,*/std::string title, int characterSize, sf::Vector2f position, sf::Color color)
{
//text.setFont(loadFont);
text.setString(title);
text.setCharacterSize(characterSize);
text.setPosition(position);
text.setColor(color);
}
//function for converting string
//function for updating ball
//function for random number
//function for Colission
//function for computer AI
};
The thing is, i want to add sf::Font font as one of the parameters since it has a method called, setFont that would work perfectly with the text constructor. However, i'm not sure how to call it or set it up in the class. I first inserted, sf::Font font, as one of the parameters and called it using text.setFont(font); but once i was in the main function, i didnt know what to put in the parameter for font:
Game startTitle(Game(/*sf::Font loadFont ,*/"Start", 24, sf::Vector2f(0,0), sf::Color::White));
I though i could simply use, loadFromFile("file.png"); but that doesnt work, how can i work around this? Also i was wondering that with private variable members, the best way to call them into main would be to use getter/setter methods, correct?