I'm trying to declare a sf::Drawable *
property inside my class body.
the code i already wrote:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
class View{
protected:
sf::Drawable *view;
};
and inside the class constructor, I want to use the view
properties:
class View{
public:
View(){ view->...}
protected:
sf::Drawable *view;
}
but I cannot access any of the sf::Drawable
methods.
I get the No member named 'setPosition' in 'sf::Drawable'
warning from IDE.
the only code suggestion i get from code completer is:
draw(RenderTarget& target, RenderStates states)
Indeed, sf::Drawable
doesn't have a setPosition
method. You could instead use sf::Transformable*
, which does have setPosition
.
If you need to have drawable properties, then...
sf::Shape
, sf::Sprite
, or sf::Text
.ShapeView
, SpriteView
, TextView
).dynamic_cast
, as suggested by TheMedicineSeller. But this will incur a small runtime cost.