Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - yuri00

Pages: [1]
1
Graphics / background image to change to another image after a few seconds.
« on: September 22, 2017, 12:57:50 am »
I want to change the background of the Spirit. However, if I use loadFromFile, I can see only the last image.
....OTL.........
I want the background image to change to another image after a few seconds.

int main()
{
        int i = 0;
        std::string link;
        char fileName = '0';
        std::string str(".jpg");
        std::string str0("tutorial/");
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
        sf::Texture texture;
        if (!texture.loadFromFile("images/bg.png"))
                return EXIT_FAILURE;

        sf::Sprite sprite(texture);
        // Create a graphical text to display

        // Start the game loop
        while (window.isOpen())
        {
                // Process events
                sf::Event e;
                while (window.pollEvent(e)){
                        // Close window : exit
                        if (e.type == sf::Event::Closed)
                                window.close();
                        if(i<6){
                                        fileName++;
                                        std::cout << fileName << std::endl;
                                        link = str0 + (char)fileName + str;
                                        _sleep(1000);
                                        texture.loadFromFile(link);
                                       
                                        i++;   
                        }
                }//while (window.pollEvent(e))
               
                window.clear();
                // Draw the sprite
                window.draw(sprite);
                window.display();
        }//while (window.isOpen())
        return EXIT_SUCCESS;
}

Pages: [1]
anything