Here's a small mock up/example of what I have:
class MainObject
{
private:
sf::RenderWindow window;
Map map;
public:
//Constructor/destructor
void Draw()
{
window.clear();
map.Draw(&window);
window.display();
};
}
class Map:
{
private:
sf::Texture texture;
std::vector<sf::Sprite*> spv;
sf::Sprite testsp; //Test case.
public:
//Constructor and destructor that load a texture and setup sprites - These work! Really, they do!
void Draw(sf::RenderWindow* window);
{
for (std::vector<int>::size_type tile = 0; tile != mapTiles.size(); ++tile)
{
window->draw(*spv[tile]);
}
window->draw(testsp); //I thought I made a mistake in the vector or iteration but even this fails.
};
}
This makes sense, right? I'm trying to draw a sprite (more accurately, a set of sprites) on the RenderWindow passed by reference from inside a child object. My problem is that nothing gets drawn on the screen.
Formerly, MainObject itself held the texture and sprite:
class MainObject
{
private:
sf::RenderWindow window;
sf::Texture texture;
sf::Sprite sprite;
public:
//Constructor/destructor
void Draw()
{
window.clear();
window.draw(sprite);
window.display();
};
}
This worked.
Clear() works because I can change the color the window refreshes to. I tried moving the whole clear/draw/display cycle inside of Map but had no success.
I realize this might be very little to work on. Shall I post a more in-depth description with parts from my actual code?