Hi there,
For a label that I'm creating on my main menu, I want it to animate over 3 colors in 9 seconds. The 3 color RGBA values are: (255, 255, 255, 50), (0, 161, 94, 50), (102, 0, 0, 50). To give it the "gradual" effect, I want it to increase or decrease the RGBA values of an sf::Color every millisecond. In order to get the value to increase or decrease per millisecond, I just found the difference of the respected values and divided it by 1000. Here's my (unworking) code that I've written:
(FYI: m_totalTime is a private float value in a class, m_animated_label_clock is a sf::Clock private member, and m_label_color is a sf::Color private member.)
if (m_totalTime <= 3)
{
if (m_animated_label_clock.getElapsedTime().asMilliseconds() == 0.001)
{
m_label_color.r -= 0.085;
m_label_color.b -= 0.0313;
m_label_color.g -= 0.0683;
}
}
else if (m_totalTime > 3 && m_totalTime <= 6)
{
if (m_animated_label_clock.getElapsedTime().asMilliseconds() == 0.001)
{
m_label_color.r += 0.034;
m_label_color.b -= 0.0536;
m_label_color.g -= 0.0313;
}
}
else if (m_totalTime > 6 && m_totalTime <= 9)
{
if (m_animated_label_clock.getElapsedTime().asMilliseconds() == 0.001)
{
m_label_color.r += 0.102;
m_label_color.b -= 0.161;
m_label_color.g -= 0.094;
}
}
m_totalTime += m_animated_label_clock.getElapsedTime().asMilliseconds();
m_animated_label_clock.restart();
Thanks for any and all help!