local function textFadeIn(group,i) if group[i] ~= nil then transition.fadeIn( group[i], { time = 1000, onComplete = textFadeIn(group,i+1)} ) end end textFadeIn(textGroup,1)
Hi all, I am new to Corona SDK. I want to fade in all text object in a display group one by one. The group[i+1] should start the transition after the group[i] complete the transition. However, in the above code, all the object will transition at the same time.
add a delay field to the fadeIn function … multiply the delay time by i, then each item will fade in
local function textFadeIn(group, i) if group[i] ~= nil then transition.fadeIn( group[i], {delay = i \* 4000, time = 1000, onComplete = textFadeIn(group, i+1)} ) end end
as in nearly all cases, there are multiple ways to do things… this way works, but there are likely more efficient wats to do the same thing.
If you want the first image to start fade in immediately, just change the delay argument to this : delay = (i-1) * 4000
Chris is correct here. An anonymous function is probably the best way to do what you are wanting to do there. Mine was just a quick ‘hack’ fix, which works, but it’s bad because it ignores the issue that Chris was smart enough to point out.
It is best to do it the right way. But more importantly, it would be most helpful if you do take the time to read Rob’s explanation link Chris provided. Rob is excellent at explaining these type things. Once you get a grasp of how it works and why; it will help save you a lot of headaches later on.
add a delay field to the fadeIn function … multiply the delay time by i, then each item will fade in
local function textFadeIn(group, i) if group[i] ~= nil then transition.fadeIn( group[i], {delay = i \* 4000, time = 1000, onComplete = textFadeIn(group, i+1)} ) end end
as in nearly all cases, there are multiple ways to do things… this way works, but there are likely more efficient wats to do the same thing.
If you want the first image to start fade in immediately, just change the delay argument to this : delay = (i-1) * 4000
Chris is correct here. An anonymous function is probably the best way to do what you are wanting to do there. Mine was just a quick ‘hack’ fix, which works, but it’s bad because it ignores the issue that Chris was smart enough to point out.
It is best to do it the right way. But more importantly, it would be most helpful if you do take the time to read Rob’s explanation link Chris provided. Rob is excellent at explaining these type things. Once you get a grasp of how it works and why; it will help save you a lot of headaches later on.