这不起作用,我想要的。当我这样做时它只从黑色转换为白色但是如果我删除参数textToFlash并将其留空并将myTextObject放在其工作的函数中的其余textToFlash对象的位置并闪烁不同的颜色。
local myTextObject = display.newText("Hello, World", 160, 25, "Arial", 60)
function flashing_text(textToFlash)
local r = math.random(0,100)
local g = math.random(0,100)
local b = math.random(0, 100)
if(textToFlash.alpha < 1) then
textToFlash:setFillColor(r/100,g/100,b/100)
transition.to( textToFlash, {time=490, alpha=1})
else
transition.to( textToFlash, {time=490, alpha=0.1})
end
end
txt_flash = timer.performWithDelay(550, flashing_text(myTextObject), 0)
有人能做到这一点吗?任何帮助或反馈将不胜感激
答案 0 :(得分:1)
为了让您的功能发挥作用。您必须在计时器功能中添加功能()结束。像这样 timer.performWithDelay(延迟,函数()callYourOtherfunction()结束,0)
local myTextObject = display.newText("Hello, World", 160, 25, "Arial", 60)
function flashing_text(textToFlash)
local r = math.random(0,100)
local g = math.random(0,100)
local b = math.random(0, 100)
if(textToFlash.alpha < 1) then
textToFlash:setFillColor(r/100,g/100,b/100)
transition.to( textToFlash, {time=490, alpha=1})
else
transition.to( textToFlash, {time=490, alpha=0.1})
end
end
txt_flash = timer.performWithDelay(550, function() flashing_text(myTextObject) end, 0)
干杯。在我的模拟器伙伴中工作。快乐的编码。