Hello Guest

Author Topic: How do you animate transparency using iTween?  (Read 17904 times)

Disastercake

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Disastercake
How do you animate transparency using iTween?
« on: May 21, 2012, 02:07:14 am »
I'm trying to use iTween to animate the transparency of a 2D Toolkit sprite object.

However, when trying to use a change color function, I am getting a compiler error that states the "material does not have a color attribute" or something along those lines.

Any idea how to add a color value to my 2D Toolkit Sprite?  Or is there a work around that I should be using?

Thanks.
« Last Edit: May 21, 2012, 02:11:17 am by Disastercake »
Working on Soul Saga, an upcoming anime adventure RPG game by Disastercake.
www.disastercake.com

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How do you animate transparency using iTween?
« Reply #1 on: May 21, 2012, 02:42:41 am »
You shouldn't be animating the .color attribute on a material. This will globally change everything and isn't a good idea at all. What you should be animating is the .color property of the sprite.

SyndicatePlus

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How do you animate transparency using iTween?
« Reply #2 on: July 07, 2012, 02:14:17 am »
Yeah, I can't figure this out either

iTween.FadeTo( SpriteName.color , iTween.Hash( "alpha" , 0.0f , "time" , .3 , "easeType", "easeInSine") );
or
iTween.FadeTo( SpriteName.gameObject , iTween.Hash( "alpha" , 0.0f , "time" , .3 , "easeType", "easeInSine") );

Do not work.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How do you animate transparency using iTween?
« Reply #3 on: July 07, 2012, 03:13:23 am »
Are you using a transparent shader? It won't work on solid ones.

SyndicatePlus

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How do you animate transparency using iTween?
« Reply #4 on: July 07, 2012, 04:54:36 am »
I tried changing the shader type. This works and it will animate, however the Sprites are very opaque/transparent no matter what value I give it.

If I do this : sprite.color = new Color(1, 1, 1, 0.5f);  It will give me what I am looking for, just not as an animation. Are there any other Tween tools that can do this correctly?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How do you animate transparency using iTween?
« Reply #5 on: July 07, 2012, 12:26:12 pm »
I could be completely wrong here, but I don't belive iTween will interpolate properties. I've not spent enough time trying it that's for sure.

The excellent HOTWEEN does work though. I was happy enough with it that I didn't bother with anything else. It comes with a visual editor - you can use that to figure out what you need to call should you wish to code everything.
http://www.holoville.com/hotween/