#include <SFML/Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
class player {
public:
int the = 5; //Works
sf::Font font; //Works
sf::RectangleShape shape(sf::Vector2f(50, 50)); //Does not
sf::CircleShape circle(50); //Does not
};
int main()
{
sf::CircleShape circle2(50); //Does
It gives me the error "Function definition for ( shape name, not class) not found."
I don't think this is a sfml linking problem, but I could be wrong.
I am using VS 2015, If that matters.
Thanks in advance.
Bonediggerninja,
I don't know exactly what you are trying to do but initializing the
shapes should be done with the object not inside the class.
This will compile:
#include <SFML/Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
class player {
public:
int the = 5; //Works
sf::Font font; //Works
sf::RectangleShape shape;
sf::CircleShape circle;
};
int main()
{
player player1;
player1.circle.setRadius(50);
player1.shape.setSize(sf::Vector2f(50, 50));
}
You can also initialise members in a constructor:
class player {
public:
int the;
sf::Font font;
sf::RectangleShape shape;
sf::CircleShape circle;
player()
{
the = 5;
shape.setSize(sf::Vector2f(50, 50));
circle.setRadius(50.f);
}
};
or directly in its initialisation list:
class player {
public:
int the;
sf::Font font;
sf::RectangleShape shape;
sf::CircleShape circle;
player()
: the(5)
, font()
, shape(sf::Vector2f(50, 50))
, circle(50)
{
}
};