大家好,小弟又来啦,嘎嘎,
好啦 小弟不废话了,直接上代码
大家先用NGUI创建好技能的按钮以及遮罩,其中上图的精灵就是遮罩
UISprite sprite;
private bool cd_bool = false;
public GameObject sprites;
private bool iscdlengque = false;
// Use this for initialization
void Start () {
sprite = gameObject.GetComponentInChildren<UISprite>();
sprites = GameObject.Find("Sprite");
//NGUITools.SetActive (spritessss, falses);
//开始先把遮罩隐藏掉
sprites.SetActive (false);
// sprites = GameObject.Find ("sprite");
// sprites.SetActive (false);
//Debug.Log(sprite.name);
}
void OnClick()
{
//if(sprite.fillAmount == 0)
cd_bool = true;
sprites.SetActive (true);
if (iscdlengque == false)
{
Debug.Log ("在这里加入具体的技能效果");
sprite.fillAmount = 1;
}
}
// Update is called once per frame
void Update () {
if(cd_bool)
{
sprite.fillAmount -= 0.01f;
if(sprite.fillAmount >=0.01)
{
iscdlengque = true;
}
if(sprite.fillAmount == 0)
{
iscdlengque = false;
}
}
}
主要的原理就是控制遮罩的fillamount(填充量)
1表示填满,0表示空
好啦,到这里了,可能有点不太详细,嘎嘎,非常感谢各位大神的指点