Hey Guys!
I just recently started using SFML with C++ and I really enjoy it. However, because I'm new, I have already run into a problem. I am trying to recreate Space Invaders. To create the enemy, I assume my options are to create the enemy, and then copy and paste that code again and again. My other reasonable and cleaner option was to create a class. My problem is, I can't get my classes to work in SFML. Can someone help?
The first thing I do is create a class and then create an object:
//Creating an Enemy
class Enemy
{
public:
Enemy::Enemy()
{
sf::RectangleShape shape(sf::Vector2f(25, 25));
}
};
Enemy enemyOne;
After that, I call the enemyOne object in the window.draw()
window.draw(enemyOne);
However I get the error:
Severity Code Description Project File Line
Error C2664 'void sf::RenderTarget::draw(const sf::Vertex *,size_t,sf::PrimitiveType,const sf::RenderStates &)': cannot convert argument 1 from 'main::Enemy' to 'const sf::Drawable &' SFML Test c:\users\calvin\documents\visual studio 2015\projects\sfml test\sfml test\source.cpp 71
and I get this error:
Severity Code Description Project File Line
Error (active) no instance of overloaded function "sf::RenderWindow::draw" matches the argument list SFML Test c:\Users\Calvin\Documents\Visual Studio 2015\Projects\SFML Test\SFML Test\Source.cpp 71
What am I doing wrong and how can I fix it?
Any help would be GREATLY appreciated. I have been making games with game engines (Unity, GM, etc.) and really want to start using SFML.