I want to create a continuous fade in and out.
I'd like to have some function F(time) that returns values increasing from 0 to 255, then from 255 back down to -255, and repeats, as time progresses.
|
I want to create a continuous fade in and out. I'd like to have some function |
|||||||||||
|
|
I know the question has been answered but just for old times sake here is the optimized classic way (works only with fixed steps but takes only 2 bytes ;-) )
|
|||||||||
|
|
What you're looking for is a periodic function like Sine. Here's how you can use Sine to achieve what you're looking for:
It's as simple as that. Since |
|||||||||||
|
|
You can also use a tweening library to smoothly fade in and out such as cpptweener. |
|||||
|