android - Corona SDK 中的转换

标签 android iphone transitions coronasdk

如何在 corona sdk 中为改变颜色提供过渡。

我试过了,还是不行

transition.to (show_text, {time=1000,color="rgb(0,0,0)"});

最佳答案

以下技巧有效。不幸的是,它不允许在不使用多个过渡的情况下进行非常复杂的颜色操作:

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})

关于android - Corona SDK 中的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8425725/

相关文章:

android - 打瞌睡模式处理

iphone - 如何使 NSManagedObject NSString 属性与 "copy"而不是 "retain"?

ios - 位置回调后 UITableViewCell 不更新,直到滚动或选择

iphone - 无法在 UIView 中制作流畅的动画

durandal - Durandal 过渡在哪里?

jquery - 全屏响应 3d css3 立方体底部关闭

android - 有没有办法在可绘制 XML 中使用自己的 Drawable 类?

android - 从全屏切换到非全屏弹出/幻灯片

android 图片保存到 res/drawable 文件夹

html - 为什么当元素的 child 的过渡结束时可以运行 transitionend 事件?