我可以更改文本字段的转换颜色吗? 我尝试像这样正常的转换,但没有奏效。Corona SDK - 我如何更改颜色文本与转换?
explainer = display.newText("my text", 100,100,"Hiragino Maru Gothic Pro",30)
transition.to(explainer, { time=100, color="rgba(255,0,0)" })
我可以更改文本字段的转换颜色吗? 我尝试像这样正常的转换,但没有奏效。Corona SDK - 我如何更改颜色文本与转换?
explainer = display.newText("my text", 100,100,"Hiragino Maru Gothic Pro",30)
transition.to(explainer, { time=100, color="rgba(255,0,0)" })
你真的不能用transition.to做到这一点。您必须在enterFrame监听器中执行此操作,并在每个步骤中增加R,G,B值。
这里有一个代码,让你制作一个blink
效果。您可以删除改变增量的一部分,它会为你工作:
local min_r,min_g,min_b=100,100,255 -- Initial color
local max_r,max_g,max_b=255,255,255 -- End color
local color_steps=15 -- Adjust this to make it more fast/slow
local current_step=0
local increment=1
local step_r=(max_r-min_r)/color_steps
local step_g=(max_g-min_g)/color_steps
local step_b=(max_b-min_b)/color_steps
function blink()
if (rowPlayerName and rowPlayerName["text"] and rowScore and rowScore["text"]) then
rowPlayerName:setTextColor(min_r+current_step*step_r, min_g+current_step*step_g, min_b+current_step*step_b)
rowScore:setTextColor(min_r+current_step*step_r, min_g+current_step*step_g, min_b+current_step*step_b)
current_step=current_step+increment
if (current_step>=color_steps) then
current_step=color_steps-1
increment=-increment
elseif (current_step<0) then
current_step=0
increment=-increment
end
timer.performWithDelay(50, blink)
end
end
blink()
在这种情况下,rowPlayerName
和rowScore
是2 display.newText
需要改变在一起。
你也可以做的,是刚刚把另一对象在它与不同的颜色,然后使用transition.to方法改变其alpha设置为0。这个对象阿尔法属性设置为1
[转型的可能重复Corona SDK](http://stackoverflow.com/questions/8425725/transition-in-corona-sdk) – Kamiccolo
哦是对不起... – Simonini
不用担心;)该线程没有正确命名... – Kamiccolo