Adding onComplete to this wrapper?

I was looking around at the color transition wrapper from atoko and was trying to figure out how to add onComplete function to it? in the comments of the page someone had mentioned that it could be done but seeing as I’m new to coding, I can’t figure it out. 

Can anyone help me with this because I really need to use it.

cheers.

Color transition wrapper:

https://developer.coronalabs.com/code/color-transition-wrapper#comment-form

you can use transition.to on colors in graphics2.0

transition.to( objectName.fill, {time=1000, r1=0,g1=0,b1=0,a1=1, onComplete=functionName})

and if the color is a gradient you add r2,g2,b2,a2

Hi jstrahan, thanks for the reply. I tried using your code above but can’t get it to change in simulator over time. 

basically I have a large imageRect which serves as the background which I want to transition colors too. 

background = display.newRect(0, 0, 800, 500) background.anchorX = 0.0; background.anchorY = 0.0; background:setFillColor(1/255, 82/255, 135/255) 

how would I change this to white after 2 second for example.

Cheers

think you have to color with
background .fill ={ r,g,b,a}
for it to work

also you can use display.setDefaults() to color background without using a rect unless you need touch event on it

I set it up so that it colours with.fill but no change happens from the original colour. 

Here is what I have: 

background = display.newRect(0, 0, 900, 1425) background.anchorX = 0.0; background.anchorY = 0.0; background.fill = { 1.0, 0.5, 1.0 } transition.to( background.fill, {time=1000, r1=0.5,g1=1.5,b1=0,5})

you can use transition.to on colors in graphics2.0

transition.to( objectName.fill, {time=1000, r1=0,g1=0,b1=0,a1=1, onComplete=functionName})

and if the color is a gradient you add r2,g2,b2,a2

Hi jstrahan, thanks for the reply. I tried using your code above but can’t get it to change in simulator over time. 

basically I have a large imageRect which serves as the background which I want to transition colors too. 

background = display.newRect(0, 0, 800, 500) background.anchorX = 0.0; background.anchorY = 0.0; background:setFillColor(1/255, 82/255, 135/255) 

how would I change this to white after 2 second for example.

Cheers

think you have to color with
background .fill ={ r,g,b,a}
for it to work

also you can use display.setDefaults() to color background without using a rect unless you need touch event on it

I set it up so that it colours with.fill but no change happens from the original colour. 

Here is what I have: 

background = display.newRect(0, 0, 900, 1425) background.anchorX = 0.0; background.anchorY = 0.0; background.fill = { 1.0, 0.5, 1.0 } transition.to( background.fill, {time=1000, r1=0.5,g1=1.5,b1=0,5})

UPDATE!

Hello guys,

I added the onComplete callback for this library, this time done right.

You can find the whole implementation in the link below,

http://pastebin.com/n23xhk3X

Note that the table parameter is optional,

Example usage:

function \_M:colorTransition( obj, colorFrom, colorTo, time, {onComplete=foo, delay=time, ease=some\_easing} )

Cheers!

UPDATE!

Hello guys,

I added the onComplete callback for this library, this time done right.

You can find the whole implementation in the link below,

http://pastebin.com/n23xhk3X

Note that the table parameter is optional,

Example usage:

function \_M:colorTransition( obj, colorFrom, colorTo, time, {onComplete=foo, delay=time, ease=some\_easing} )

Cheers!