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 - xYodax

Pages: [1]
1
Graphics / Re: how to set background.
« on: July 13, 2021, 07:20:50 pm »
The problem here is that while using the .setTexture() function and an sf::Texture the .setTexture() function expects to be given a pointer so:

RenderWindow window(VideoMode(1024, 786, 32), "Test 32");

        Texture texture;
        texture.loadFromFile("background.png");
        Sprite sprite;
        Vector2u size = texture.getSize();
        sprite.setTexture(&texture);  //This is where you add an & to designate texture as a pointer
        sprite.setOrigin(size.x / 2, size.y / 2);

        while (window.isOpen())
        {
                Event e;
                while (window.pollEvent(e))
                {
                        if (e.type == Event::Closed)
                                window.close();
                }
                window.draw(sprite);
                window.display();
        }

Pages: [1]
anything