如何在corona sdk中更改顏色的轉換。Corona SDK中的轉換
我已經試過這樣的,但它不工作
transition.to (show_text, {time=1000,color="rgb(0,0,0)"});
如何在corona sdk中更改顏色的轉換。Corona SDK中的轉換
我已經試過這樣的,但它不工作
transition.to (show_text, {time=1000,color="rgb(0,0,0)"});
在瞬間電暈的過渡API不支持彩色。你可以嘗試使用...
show_text:setTextColor(red, green, blue)
...一個循環內,並且只畫和你改變了顏色值刪除文本對象。
以下技巧有效。遺憾的是它並沒有允許非常複雜的顏色的處理,而無需使用多個轉變:
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})
這裏鏈接使用這一點,它工作正常 http://developer.coronalabs.com/code/color-transition-wrapper
過渡可以用來修改任何對象的任何數值/表。 – Krystian