UGUI实现技能cd效果
2016-03-07 14:08
471 查看
、using UnityEngine;
using System.Collections;
//导入这个类 (自动导入插件)
using UnityEngine.UI;
public class SkillItem : MonoBehaviour {
// Use this for initialization
//冷却cd时间
public float cdTime = 2;
private bool isStartTimer;
private float time;
private Image filledImage;
public KeyCode myKey;
void Start () {
filledImage = transform.Find ("mask").GetComponent<Image> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (myKey))
{
isStartTimer = true;
}
if (isStartTimer)
{
time += Time.deltaTime;
filledImage.fillAmount
= (cdTime - time) / time;
if (time >= cdTime)
{
filledImage.fillAmount = 0;
time = 0;
isStartTimer = false;
}
}
}
public void onClick()
{
isStartTimer = true;
}
}
mask这里设置为Filled
using System.Collections;
//导入这个类 (自动导入插件)
using UnityEngine.UI;
public class SkillItem : MonoBehaviour {
// Use this for initialization
//冷却cd时间
public float cdTime = 2;
private bool isStartTimer;
private float time;
private Image filledImage;
public KeyCode myKey;
void Start () {
filledImage = transform.Find ("mask").GetComponent<Image> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (myKey))
{
isStartTimer = true;
}
if (isStartTimer)
{
time += Time.deltaTime;
filledImage.fillAmount
= (cdTime - time) / time;
if (time >= cdTime)
{
filledImage.fillAmount = 0;
time = 0;
isStartTimer = false;
}
}
}
public void onClick()
{
isStartTimer = true;
}
}
mask这里设置为Filled
相关文章推荐
- UIMenuController
- iOS _ UITableViewCell 分隔线颜色
- UGUI笔记
- javax.persistence.NonUniqueResultException: result returns more than one elements
- UI总结
- Fibonacci sequence 求余数
- UESTC 1063 秋实大哥与妹纸 二叉堆(大根树)
- 0018-【EasyUI】combotree和combobox模糊查询
- 矩阵的运算 --- 矩阵快速幂(UVA10689 - Yet another Number Sequence)
- ScrollView
- Sublime Text 3 (Build 3103) 注册码
- [easyui]总结一下目前项目里遇到的小麻烦
- iOS7 UITabBar自定义选中图片显示为默认蓝色的Bug
- 让zepto支持requirejs的方法
- C# - Dictionary join keys or join Values
- 关于PROPAGATION_REQUIRES_NEW和PROPAGATION_NESTED事务的比较
- lcs hdu1503 Advanced Fruits
- iOS集成环信聊天和EaseUI之后出现警告:Warning! ivar size mismatch in PSUICollectionView_ - can't change the supercl
- iOS键盘类型UIKeyboardType(模拟器效果+真机效果)
- AsyncQueryHandler 异步查询数据