How to delay a for loop? In example:
for i = 1, 11 do
whiterect.alpha = whitelevel
--delay(time), wait(time) or something like that.
whitelevel = whitelevel + 0.1
end
I tried:
for i = 1, 11 do
whiterect.alpha = whitelevel
timer.performWithDelay(500)
whitelevel = whitelevel + 0.1
end
This did not work. I mean it didn’t give me any errors but it just flashed into place. I apologize if this is really newbie stuff but I’m new to corona. Basically I’m attempting to have a white rectangle fade in.
If you want to have a white rectangle fade in, you should use the transition library (http://docs.coronalabs.com/api/library/transition/index.html). You could simply do:
[lua]
whiterect.alpha=0
transition.to(whiterect, {time=500, delay=1000, alpha=1})
[/lua]
This will fade in the whiterect over half a second (500 milliseconds) after first waiting for 1 second (1000 milliseconds).
- Andrew
Thanks, this worked.
If you want to have a white rectangle fade in, you should use the transition library (http://docs.coronalabs.com/api/library/transition/index.html). You could simply do:
[lua]
whiterect.alpha=0
transition.to(whiterect, {time=500, delay=1000, alpha=1})
[/lua]
This will fade in the whiterect over half a second (500 milliseconds) after first waiting for 1 second (1000 milliseconds).
- Andrew
Thanks, this worked.