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

Author Topic: Draw Sprite  (Read 1733 times)

0 Members and 1 Guest are viewing this topic.

SEnergy

  • Newbie
  • *
  • Posts: 20
    • View Profile
Draw Sprite
« 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
« Last Edit: June 08, 2012, 03:33:22 pm by SEnergy »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Draw Sprite
« Reply #1 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.
Laurent Gomila - SFML developer

SEnergy

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Draw Sprite
« Reply #2 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