PDA

View Full Version : Opposite of fadeOverTime()?



raphael
20th March 2023, 07:01
Hello
I'm trying to make the opposite of fadeOverTime()

I mean I try to make the alpha to increase over time, progressively, according to a time value

Could you help me please?

I will post my results here

I'm thinking about something like this:



progressiveAlpha(hud, time)
{
hud.alpha = 0;
progresstime = 0;
while (progresstime < time)
{
progresstime += 0.05;

hud.alpha += 0; //...

wait 0.05;
}
}

IzNoGoD
21st March 2023, 17:54
Yes, use fadeovertime.

hud.alpha = 0;
hud fadeOverTime(1);
hud.alpha = 1;

Done.

raphael
22nd March 2023, 01:37
It works great thank you very much

Does the code after fadeOverTime() get executed after it's amount is passed?

I'm not sure to understand, I have this code for something else:



self._welcomehud setText(&"Welcome");
self._welcomehud.fontScale = 1.3;

wait (2);

self._welcomehud fadeOverTime(1);
self._welcomehud.alpha = 0;

wait (1);

if (isdefined(self._welcomehud))
{
self._welcomehud destroy();
}


Is wait (1); useless here?

If I try to remove it and the hud still gets destroyed after 1sec, I will tell

IzNoGoD
22nd March 2023, 05:10
1. set up initial alpha with .alpha
2. call fadeovertime(time_goes_here)
3. set new, desired alpha that should be faded towards
4. fadeovertime will do stuff in the background, as a separated thread
5. setting alpha will override fadeovertime (=cancel it, and set the new alpha immediately)
6. after time_goes_here your hud will have the new alpha


So, if you want a "breathing" style hud, you should do something like this:



hud.alpha = 0;
while(true)
{
hud.fadeovertime(1);
hud.alpha = 1;
wait 1;
hud.fadeovertime(1);
hud.alpha = 0;
wait 1;
}

raphael
22nd March 2023, 06:28
Thank you so much IzNoGoD