I'm trying to load sprites through the renderwindow that I'm pointing to, it seems to work fine without errors, but when loading a sprite all I get is the white dot. I've tried everything I can think of, and still it refuses to render.
.h
class Invador
{
public:
Invador(sf::RenderWindow& window) :
m_window(window)
{}
float Draw()
{
imag.LoadFromFile("sprite.png");
sprite.SetPosition(10,1);
m_window.Draw(sprite);
return 0;
}
private:
sf::RenderWindow& m_window;
sf::Image imag;
sf::Sprite sprite;
};
main
int main()
{
sf::RenderWindow window(sf::VideoMode(SC_WIDTH, SC_HEIGHT, 32), "SFML Window");
Invador Draw(window);
while (window.IsOpened())
{
sf::Event Event;
while (window.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
window.Close();
}
float elapsedTime = window.GetFrameTime();
/*cout << elapsedTime * 100 << endl;*/
window.Clear();
Draw.Draw();
window.Display();
}
return EXIT_SUCCESS;
}
imag.LoadFromFile("sprite.png");
sprite.SetPosition(10,1);
m_window.Draw(sprite);
???
First off, you load the texture file in every frame - and then you don't even use it. You load a texture and don't assign it to the sprite. Or you're leaving relevant code out that we can't see.
Apart from that, why does "Draw" return a float value of zero?
Also, you might want to update to SFML 2 soon, the release candidate can be downloaded already. 1.6 is not really supported anymore.