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

Author Topic: Counter without background  (Read 1088 times)

0 Members and 1 Guest are viewing this topic.

schipleon

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Counter without background
« on: July 06, 2016, 12:04:04 pm »
Hello!
I'm rather new to SFML and have been searching this forum as well for alternatives, without success.

I've a counter which is drawn to the screen by the label-creator below.
Every time the counter is increased, a white rectangle is erasing the number and as such the new number is displaying with the old text erased.

The problem now, is that I cannot have any nice background, because obviously there is a white rectangle all the time.

How to solve this problem? Any ideas?

The best situation would be that the changing number (or changing string) is deleted automatically without the need of any color, to put the new output on top. In such a way at least I can have a background. Do you think that's possible?

All the best!
« Last Edit: July 08, 2016, 09:52:29 am by schipleon »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10997
    • View Profile
    • development blog
    • Email
AW: Counter without background
« Reply #1 on: July 06, 2016, 12:21:33 pm »
You're making things too complicated.just erase the whole window, draw the background you want, generate the needed string and draw it as text.
No need to keep track of the old text or any white rectangles.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10997
    • View Profile
    • development blog
    • Email
AW: Counter without background
« Reply #2 on: July 06, 2016, 01:48:08 pm »
You should always clear the full screen and redraw everything. Don't try to only redraw parts of the screen.

You rendering part of the loop should always look similar to:
window.clear()
window.draw(x)
window.draw(y)
window.draw(z)
...
window.display()
« Last Edit: July 06, 2016, 01:50:02 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/