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

Author Topic: Clear() method overwrites sprite drawing  (Read 1441 times)

0 Members and 1 Guest are viewing this topic.

shruubi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Clear() method overwrites sprite drawing
« on: November 12, 2011, 01:27:53 pm »
So i've just picked up SFML for my first romp into using real graphics for programming (and so far i love it), however i am having a problem with sprite drawing and my Clear() method.

whenever i call the Clear() method all my sprites that work and draw properly without it suddenly stop drawing altogether and stop existing. I have a feeling i am doing something very basic wrong, or i have put code in the wrong place.

Code: [Select]

while(true)
{
app.Clear(sf::Color(0, 255, 255));
app.Display();
app.Draw(player.drawsprite());
float ElapsedTime = app.GetFrameTime();

if(app.GetEvent(Event))
{
if(app.GetInput().IsKeyDown(sf::Key::Up))
{
player.move_up();
}
if(Event.Type == Event::Closed)
{
return EXIT_SUCCESS;
}
if(Event.Type == Event::KeyPressed && Event.Key.Code == Key::Escape)
{
return EXIT_SUCCESS;
}
}
}


any help would be much appreciated.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Clear() method overwrites sprite drawing
« Reply #1 on: November 12, 2011, 02:18:47 pm »
You need to call Display() after Draw(). Look at the SFML tutorials and examples...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

shruubi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Clear() method overwrites sprite drawing
« Reply #2 on: November 12, 2011, 02:26:58 pm »
see, i knew it was some stupid mistake. thank you for helping me realize my idiocy.  :)