Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: gameCoder on January 07, 2013, 03:58:05 PM

Title: Make a sprite fade out on mouse click
Post by: gameCoder on January 07, 2013, 03:58:05 PM
Hi,
I have code that already detects a mouse click on a sprite , based on the presence of its collider.

Is there a way I can make a UISprite fade out on mouse click?

I changed the alpha to 0 and that totally made the sprite disappear. No other alpha value seems to have any effect.

Thanks
Title: Re: Make a sprite fade out on mouse click
Post by: cayou on January 07, 2013, 04:01:56 PM
You have to change the alpha value on time.
The basic way is to change it into an Update function, decrementing it like this:

  1. float speed; //speed of fadeoff.
  2.  
  3. void Update()
  4. {
  5.     myWidget.alpha -= Time.deltaTime * speed;
  6. }
  7.  

Maybe it exists a tween function in NGUI that does the job for you, or you can also use a tween plugin (like HOTween) to perform it.
Title: Re: Make a sprite fade out on mouse click
Post by: ArenMook on January 07, 2013, 11:10:54 PM
UITweenAlpha.Begin(...).