1
votes

this is not working, how I want. when I do this it only transitions once from black to white but if I remove the parameter textToFlash and leave it blank and put myTextObject in where the rest of the textToFlash objects in the function it works and flashes with different colors.

local myTextObject = display.newText("Hello, World", 160, 25, "Arial", 60)

function flashing_text(textToFlash)
    local r = math.random(0,100)
    local g = math.random(0,100)
    local b = math.random(0, 100)

    if(textToFlash.alpha < 1) then
        textToFlash:setFillColor(r/100,g/100,b/100)
        transition.to( textToFlash, {time=490, alpha=1})
    else 
        transition.to( textToFlash, {time=490, alpha=0.1})
    end
end
txt_flash = timer.performWithDelay(550, flashing_text(myTextObject), 0)

can someone make this work? any help or feedback would be thanked

1

1 Answers

1
votes

In order for your function to work. You must add function() end inside your timer function. like this timer.performWithDelay(delay, function() callYourOtherfunction() end, 0)

local myTextObject = display.newText("Hello, World", 160, 25, "Arial", 60)

function flashing_text(textToFlash)
    local r = math.random(0,100)
    local g = math.random(0,100)
    local b = math.random(0, 100)

    if(textToFlash.alpha < 1) then
        textToFlash:setFillColor(r/100,g/100,b/100)
        transition.to( textToFlash, {time=490, alpha=1})
    else 
        transition.to( textToFlash, {time=490, alpha=0.1})
    end
end
txt_flash = timer.performWithDelay(550, function() flashing_text(myTextObject) end, 0)

Cheers. Working in my simulator mate. Happy Coding.