• Create Account

### #ActualBeerNutts

Posted 01 November 2012 - 02:23 PM

You can also have your drawble classes inherit from sf::Sprite class. So, you're actual class is a sprite, and you can pass it to the App.Draw, like this:
class Drawable : public sf::Sprite
{
Drawable::Drawable(sf::Image sfImage, ...) :
sf::Sprite(sfImage)
{
//.. other constructor stuff
}
};

// list that holds eveyrthing thta can be drawn
std::vector<Drawable> DrawableList;

// called from in main loop
void DrawObjects(sf::RenderWindow &App)
{
for (int i = 0; i < DrawableList.size(); ++i) {
App.Draw(DrawableList[i]);
}
}


You get the general idea. Of course, if your drawable handle animation, then it can't be a single sprite, but this is just another option you could choose.

Good luck!

### #1BeerNutts

Posted 01 November 2012 - 02:22 PM

You can also have your drawble classes inherit from sf::Sprite class. So, you're actual class is a sprite, and you can pass it to the App.Draw, like this:
class Drawable : public sf::Sprite
{
Drawable::Drawable(sf::Image sfImage, ...) :
sf::Sprite(sfImage)
{
//.. other constructor stuff
}
};

// list that holds eveyrthing thta can be drawn
std::vector<Drawable> DrawableList;

// called from in main loop
void DrawObjects(sf::RenderWindow &App)
{
for (int i = 0; i < DrawableList.size(); ++i) {
App.Draw(DrawableList[0]);
}
}


You get the general idea. Of course, if your drawable handle animation, then it can't be a single sprite, but this is just another option you could choose.

Good luck!

PARTNERS