在Corona SDK中淡化文本颜色

时间:2014-07-24 08:21:52

标签: corona fade

我有一个颜色代码列表,想让文字像这张图片一样平滑地淡化颜色:

Fading colors

Corona有可能吗?我还没有办法做到这一点。

1 个答案:

答案 0 :(得分:2)

尝试我制作的这个功能,可能不完美,但它对我有用:

-- Transitions a display object from one color to another (based on 0 to 1 values)
function applyColorTransition(oDisplayObject, nDelay, nStartR, nEndR, nStartG, nEndG, nStartB, nEndB)
    if oDisplayObject.setFillColor then

     local nIterations = 10
     local nStepsR = (nEndR - nStartR) / nIterations
     local nStepsG = (nEndG - nStartG) / nIterations
     local nStepsB = (nEndB - nStartB) / nIterations
     local nI = 1
     timer.performWithDelay( nDelay, function()
            oDisplayObject:setFillColor(nStartR + nStepsR * nI, nStartG + nStepsG * nI, nStartB + nStepsB * nI)
        nI = nI + 1
     end, nIterations)
    end
end