setTextColor transition?

How can I modify text color with transitions?

local text1 = display.newText(“Hello World!”, 50, 50, nil, 24)  
text1:setTextColor( 255, 255, 255)  
  
function text1:tap( event )  
transition.to(text1, { setTextColor( 25, 25, 25) } ) --doesn't work   
end  
text1:addEventListener( “tap”, text1 )  

I’ve tried: setTextColor=( 25, 25, 25), setTextColor{( 25, 25, 25)}, setTextColor( 25, 25, 25), TextColor( 25, 25, 25), etc

If you know any undocumented values that can be transitioned, please post.

Thanks,
Carlos M. --Not the CEO :slight_smile: [import]uid: 10426 topic_id: 3152 reply_id: 303152[/import]

As it happens you CAN do this, but it’s kinda goofy. The following code works:

[lua]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})[/lua] [import]uid: 117383 topic_id: 3152 reply_id: 119348[/import]

Any reason why three transitions and not one?

transition.to (show_text, {time=1000,r=0, g=255, b=0}) [import]uid: 160496 topic_id: 3152 reply_id: 119369[/import]

My original example was using different easings for each but yah, for this example you probably dont need them. [import]uid: 117383 topic_id: 3152 reply_id: 119394[/import]