using UnityEngine;
using System.Collections;

public class FadeOut : MonoBehaviour 
{
	public float fadeTime;
	public tk2dSprite fadeSprite;

	private double lastTime;

	void Start () 
	{
	}

	public void Reset()
	{
		fadeSprite.color = new Color(1, 1, 1, 1);
	}

	void Update () 
	{
		if (Time.time - lastTime > fadeTime)
		{
			gameObject.SetActive(false);
		}
		else
		{
			fadeSprite.color = new Color(1, 1, 1, Mathf.Lerp(1, 0, (float)(Time.time - lastTime) / fadeTime));
		}
	}
}
