How to display blinking text over an image in Corona SDK? -
i seem have serious problems here - i'm trying display image , transition in, have blinking text on @ bottom.
function splash() local item = display.newimage("splashimage.png") item.x = display.contentwidth*0.5 item.y = display.contentheight*0.5 item.alpha=0 transition.to(item, {time =1500, alpha=1, oncomplete=blink}) end -- blinking text function blink() text = display.newtext("this blinking text", 100, 100, "arial", 22) text.x = display.contentwidth/2 text.y = display.contentheight/1.2 text.alpha=0 transition.to(text, {time =1500, alpha=1, oncomplete=blink2}) end function blink2() if (text.alpha > 0) [--this line broken apparently] transition.to(text, {time=1500, alpha=0}) else transition.to(text, {time=1500, alpha=1}) end end txt_blink = timer.performwithdelay(500, blink2, 0)
code breaks error "attempt index upvalue 'text' (a nil value)"
i'm total noob @ gentle!
your problem that, when blink2() called looks object "text" not created in time. should check first if there object called "text" or not. here new blink2() function you:
function blink2() if text ~= nil if (text.alpha > 0) transition.to(text, {time=1500, alpha=0}) else transition.to(text, {time=1500, alpha=1}) end end end
Comments
Post a Comment