Corona SDK中的过渡效果

3
如何在Corona SDK中为颜色变化添加过渡效果。
我尝试了以下方法,但它并没有起作用。
transition.to (show_text, {time=1000,color="rgb(0,0,0)"});
3个回答

2
以下技巧有效。不幸的是,如果不使用多个转换,它无法进行非常复杂的颜色处理:
local function modify(text)
    local mt = {
        r = 0,
        g = 0,
        b = 0,
        __index = function(t, k)
            if k == "r" or k == "g" or k == "b" then
                return getmetatable(t)[k]
            end
        end,
        __newindex = function(t, k, v)
            getmetatable(t)[k] = v
            if k == "r" or k == "g" or k == "b" then
                t:setTextColor(math.round(t.r or 0), math.round(t.g or 0), math.round(t.b or 0))
            end
        end
    }
    local originalSetTextColor = text.setTextColor
    text.setTextColor = function(self,r,g,b)
        mt.r = r
        mt.g = g
        mt.b = b
        originalSetTextColor(self, r,g,b)
    end
    setmetatable(text, mt)

end

local show_text = display.newEmbossedText("I am the very model of a modern major general", display.screenOriginX,0, native.systemFont, 30);
modify(show_text)
show_text:setTextColor(255,0,255)

transition.to (show_text, {time=1000,r=0,})
transition.to (show_text, {time=1000,g=255})
transition.to (show_text, {time=1000,b=0})

0

0

目前Corona的转换API不支持颜色。您可以尝试使用...

show_text:setTextColor( red, green, blue )

...在循环内部,只需绘制和擦除文本对象,同时更改颜色值。


Transition 可用于修改任何对象/表上的任何数值。 - Krystian

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接