Hi =)
I've coded a little surface class, ok it's a class that stores a set of sf:Sprites :roll: :
#include <vector>
#include <SFML/Graphics.hpp>
class Surface
{
std::vector<sf::Sprite> m_sprites;
public:
void Add(sf::Sprite &s);
void Clear();
void Display(sf::RenderWindow& rw) const;
Surface();
Surface(int reserve);
};
Surface::Surface()
{
}
Surface::Surface(int reserve)
{
m_sprites.reserve(reserve);
}
void Surface::Add(sf::Sprite &s)
{
m_sprites.push_back(s);
}
void Surface::Clear()
{
m_sprites.clear();
}
void Surface::Display(sf::RenderWindow& rw) const
{
for(unsigned int i = 0;i < m_sprites.size();i++)
rw.Draw(m_sprites[i]);
rw.Display();
}
usage:
sf::Image Image;
if (!Image.LoadFromFile("image.jpg"))
return EXIT_FAILURE;
sf::Sprite Sprite(Image);
Surface surf;
surf.Add(Sprite);
/*......*/
surf.Display(App); //App -> sf::RenderWindow
I thought it will might be useful for someone. Be careful, the sprites are copied. That makes it possible to "draw" 1 Sprite onto different surfaces...
Maybe it would be a nice idea to make real surfaces :/
Sicerely,
BloodGod