Hello Guest

Author Topic: Tween tk2dSprite color with iTween  (Read 5646 times)

JBabz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 42
  • @joe_babz
    • View Profile
    • Zombit on Facebook
Tween tk2dSprite color with iTween
« 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!!

JFBillingsley

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Tween tk2dSprite color with iTween
« Reply #1 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;
}

JBabz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 42
  • @joe_babz
    • View Profile
    • Zombit on Facebook
Re: Tween tk2dSprite color with iTween
« Reply #2 on: October 17, 2013, 04:00:32 pm »
That works great!
Thanks.