isaacjosue wrote: ↑Sun Mar 22, 2020 8:46 pm
Enjl wrote: ↑Sun Mar 22, 2020 6:16 pm
A "fade" is simply a variable that changes over time and represents an opacity between 0 and 1. For example:
Graphics.drawImage(sprite, x, y, opacity)
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions
Can't give more concrete info because the post is fairly vague.
Ok scratch the events thing and the fading out I'll figure those out.
I'm looking for a way to do a smooth and continuous fade effect in a set amount of seconds so that when x% percent of the time set has passed the opacity will be at x%.
If timer is set to 10 seconds and I wait 5, then the effect would be at 50% opacity.
My main problem is timing. I am simply unable to make the fading smooth and getting the timing right at the same time.
Interpolate a variable in onTick by 1/durationInFrames
1 second is roughly 64 frames.
So for 10 seconds:
opacity = opacity + 1/(64*10)
Turn the 10 into a variable and add a multiplier to interpolate backwards (subtract) and then you have a variable that moves between 0 and 1. Of course, ensuring that the variable never leaves the 0-1 range would be good, too, but that is easily done.