2D Toolkit Forum

2D Toolkit => Support => Topic started by: JBabz on October 16, 2013, 05:29:42 pm

Title: Tween tk2dSprite color with iTween
Post by: JBabz on October 16, 2013, 05:29:42 pm
Does anybody know specifically how to tween the color of a tk2dSprite using iTween?
There is a method called colorTo(), but that only changes the color of a texture or GUITexture.
Is there a way? Seems like it's pretty easy, and I'm just missing something.
Thanks!!
Title: Re: Tween tk2dSprite color with iTween
Post by: JFBillingsley on October 16, 2013, 11:22:53 pm
You can use iTween.ValueTo to do this... it's a little verbose, though.

Code: [Select]
void startTheTween()
{
iTween.ValueTo(yourSprite.gameObject, iTween.Hash(
"time", 0.6f,
"from", new Color(0, 0, 0, 1),
"to", new Color(1, 1, 1, 1),
"onupdate", "setSpriteColor",
"onupdatetarget", this.gameObject,
));
}

void setSpriteColor(Color c)
{
yourSprite.color = c;
}
Title: Re: Tween tk2dSprite color with iTween
Post by: JBabz on October 17, 2013, 04:00:32 pm
That works great!
Thanks.