Hello Guest

Author Topic: animated sprite fade in and out possible?  (Read 6424 times)

Tongie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
animated sprite fade in and out possible?
« on: September 22, 2012, 09:38:43 am »
can i make a animated sprite fade in and out in 2dtoolkit?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: animated sprite fade in and out possible?
« Reply #1 on: September 22, 2012, 10:47:45 am »
Yes, the easiest way to do this is probably with something like HOTween or GoKit.

Edit: Or you could just write a coroutine to do it.

Tongie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: animated sprite fade in and out possible?
« Reply #2 on: September 22, 2012, 02:55:19 pm »
I have to change the shader to transparent/diffuse and all the other texture become darker. Is there any other method to do a fade in?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: animated sprite fade in and out possible?
« Reply #3 on: September 22, 2012, 07:48:44 pm »
You don't have to change the shader, just access use sprite.color property (color.a precisely). You can do that in the interface or from script.


Tongie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: animated sprite fade in and out possible?
« Reply #4 on: September 23, 2012, 04:26:02 am »
I use itween.valueto and itween.fadeto on a animatedSprite but fail.

iTween.ValueTo(gameObject, iTween.Hash("from", 1.0f, "to", 0.0f,"time", 2.0f, "easetype", "easeInOutQuad", "onupdate", "setAlpha"));
      
iTween.FadeTo(gameObject, iTween.Hash("alpha", 0));

renderer.material.color = new Color(255,255,255,0);

none work.what am i doing wrong here?
« Last Edit: September 23, 2012, 08:10:05 am by Tongie »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: animated sprite fade in and out possible?
« Reply #5 on: September 23, 2012, 11:58:41 am »
I don't use iTween, but here is an example of modifying a textmesh using HOTween -
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,542.msg2555.html#msg2555

With a sprite, the only difference will be that the call to Commit isn't necessary.