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

Author Topic: How Do I change color of my object every second like gradient  (Read 2935 times)

0 Members and 1 Guest are viewing this topic.

rajhansk

  • Newbie
  • *
  • Posts: 21
    • View Profile
How Do I change color of my object every second like gradient
« on: August 31, 2017, 08:26:35 pm »
How Do I change color of my object every second like gradient,

I have a circle and I want to change its color with every second it passes.
Which function should I use ??

Any help will be appreciated.

Thank you

Hapax

  • Hero Member
  • *****
  • Posts: 3370
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How Do I change color of my object every second like gradient
« Reply #1 on: August 31, 2017, 09:45:59 pm »
To change/set the colour of a circle (or any standard SFML shape), use: setFillColor(sf::Color)

To animate the colour, change the colour depending on the time given by a clock (you can use sf::Time and sf::Clock).

For a small example of animating values smoothly depending on time, you can take a look at this animation of the SFML logo.
In particular, you might find most use of this section of code.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

rajhansk

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: How Do I change color of my object every second like gradient
« Reply #2 on: September 01, 2017, 06:28:08 am »
Thanks

 

anything