using UnityEngine;
using System.Collections;
public class Skill_cold : MonoBehaviour {
public UISprite cold_icon;
public float coldTime = 3f;
private bool startCold = false;
//Use this for initialization
void Start()
{
}
//Update is called one per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A) && startCold==false )
{
cold_icon.fillAmount = 1;
startCold = true;
}
Colding();
}
void Colding() //正在冷却方法
{
if (startCold)
{
//速度乘以时间间隔
cold_icon.fillAmount -= (1f / coldTime) * Time.deltaTime;
if (cold_icon.fillAmount <= 0.05f) //当小于一定值时,判定已经冷却完毕
{
cold_icon.fillAmount = 0;
startCold = false;
}
}
}
using System.Collections;
public class Skill_cold : MonoBehaviour {
public UISprite cold_icon;
public float coldTime = 3f;
private bool startCold = false;
//Use this for initialization
void Start()
{
}
//Update is called one per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A) && startCold==false )
{
cold_icon.fillAmount = 1;
startCold = true;
}
Colding();
}
void Colding() //正在冷却方法
{
if (startCold)
{
//速度乘以时间间隔
cold_icon.fillAmount -= (1f / coldTime) * Time.deltaTime;
if (cold_icon.fillAmount <= 0.05f) //当小于一定值时,判定已经冷却完毕
{
cold_icon.fillAmount = 0;
startCold = false;
}
}
}
}
技能遮罩的图片类型如上图所示Type设为Filled