Problem with fading in and out a white screen.

Hi,

I want to flash a white screen, so I made that white screen as a fullscreen rectangle and decided to increase and decrease it’s alpha to imitate the flash effect, so I wrote this:

 -- Flash screen to white timer.performWithDelay(1, function() whiteScreen.alpha = whiteScreen.alpha + 0.1 print("Increasing:" .. whiteScreen.alpha) end, 10) -- Fading out the white timer.performWithDelay(500, function() whiteScreen.alpha = whiteScreen.alpha - 0.1 print("Decreasing:" .. whiteScreen.alpha) end , 10)

The fade in is OK but the fade out runs very slow, like 1fps.

Any idea why?

Thanks.

I think I understood the documentation wrong, the delay takes effect for each call of perormWithDelay.

So how can I achieve this effect? I want to instantly fade-in my white screen, then wait 1 second, then quickly fade-out that white screen. Should I call two performWithDelay’s with closures?

essentially, you shouldn't start your second timer until first timer is complete. then call second timer with short delay just as with first.

I think I understood the documentation wrong, the delay takes effect for each call of perormWithDelay.

So how can I achieve this effect? I want to instantly fade-in my white screen, then wait 1 second, then quickly fade-out that white screen. Should I call two performWithDelay’s with closures?

essentially, you shouldn't start your second timer until first timer is complete. then call second timer with short delay just as with first.