honestly, I get this issue all the damn time. what in the hell do i have to do to get a sprite on the screen every single time! i just get a white block of whats supposed to be the image. yes i've used sfml before and this issue is random. some projects i have them working fine. this they dont.
heres the code:
#include <SFML/Graphics.hpp>
#include"Background.hpp"
int main()
{
// Create the main window-width, hieght
sf::RenderWindow window(sf::VideoMode(800, 600), "Connect 4");
window.SetFramerateLimit(15);
//load images
sf::Sprite background(Background::Load("Data/background.bmp"));
background.Move(200,200);
// Start the game loop
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();
}
// Clear screen
window.Clear();
window.Draw(background);
// Update the window
window.Display();
}
return EXIT_SUCCESS;
}
all background does is return the sprite loaded.
sf::Image Background::Load(string filename)
{
sf::Image image;
if( !image.LoadFromFile(filename) )
{
//fail
}
else
{
return image;
}
}