SFML community forums

Help => Graphics => Topic started by: SEnergy on June 08, 2012, 03:26:08 pm

Title: Draw Sprite
Post by: SEnergy on June 08, 2012, 03:26:08 pm
How am I supposed to draw sprite in SFML 2.0?

in documentation there's something like this:

int wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, INT nShowCmd)
{
        Window MainWindow(VideoMode(800, 600, 32), "SFML");

        Sprite spr;
        Texture txt;

        txt.loadFromFile("Untitled.png");
        spr.setTexture(txt);
        spr.setPosition(100, 25);

        while(MainWindow.isOpen())
        {
                Event Event;
                while(MainWindow.waitEvent(Event))
                {
                        if(Event.type == Event::Closed)
                                MainWindow.close();
                }

                MainWindow.draw(spr); // thisi s NOT working

                MainWindow.display();
        }

        return 0;
}

I've been looking at sprite/window documentation for like hour now and I can't find draw() function anywhere...

error C2039: 'draw' : is not a member of 'sf::Window'

//spr.draw() isn't also working
Title: Re: Draw Sprite
Post by: Laurent on June 08, 2012, 03:35:21 pm
The "Getting started" tutorial and the main page of the documentation both have a valid example of a program that draws something.

And your errors are not specific to SFML 2, your program wouldn't work with 1.6 either.
Title: Re: Draw Sprite
Post by: SEnergy on June 08, 2012, 03:46:19 pm
wow.. thanks... just changed Window to RenderWindow and it's working now -.-' I thought I'm gonna kill myself after that hour