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

Author Topic: A way to delete single sprites without clearing the whole screen?  (Read 2944 times)

0 Members and 1 Guest are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
I was wondering if there was a way to be able to delete a single sprite from the screen instead of clearing the whole screen then retexturing it with everything except that specific sprite. Let's say we were to have a shotgun with 8 shells and every time it was shot a shell would disappear from the ammo menu. It would seem awfully wasteful to clear the screen EVERY single time a shot went off.
Current Projects:
Technoport

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: A way to delete single sprites without clearing the whole screen?
« Reply #1 on: November 06, 2012, 01:48:20 pm »
You must clear/draw/display the whole scene every frame. Refreshing only what has changed was ok in the 90', graphics cards and APIs don't work this way anymore now.
Laurent Gomila - SFML developer

Brodal

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: A way to delete single sprites without clearing the whole screen?
« Reply #2 on: November 10, 2012, 01:39:44 pm »
Should be possible to do it if you're using primitives, Vertex or something like that to draw things onto the screen. Make the color of the thing that you want to remove into transparent color ( sf::Color::Transparent ) and draw that onto the screen at the exakt same position. Then remove the sprite. This will make it look like the sprite was removed. Things behind it will however dissapear as well. If there is something behind it just remove it and redraw what was behind it. Don't really see a good use for this when it comes to the whole screen though. A little tedious and all that.