zoukankan      html  css  js  c++  java
  • 用NGUI做一个计时条!

    1、建立两个UISprite。

    2、建立脚本CountingTime

    3、编写脚本

    public class CountTime : MonoBehaviour
    {
        //时间计时器
        public float countTime;
        //倒计时显示
        public UILabel timeCount;
      
        //计时条在准备后隐藏
        public float prograssPercent = 1f;
    
        public UISprite jinDuTiao;
        // Update is called once per frame
        void Update()
        {
            if (countTime <= 60 )
            {
                countTime += Time.deltaTime;
                timeCount.text = (60f - countTime).ToString("F0"); 
                prograssPercent -= (1f / 60f) * Time.deltaTime;
                jinDuTiao.fillAmount = prograssPercent;          
            }
        }
    }
    

     

    主要是UIsprite.fillAmount的应用,注意Fill Dir要改成Horizontal,水平。

    写的一般,不知道大家能不能理解,慢研究吧,哈哈!

  • 相关阅读:
    4月24日 PHP基础
    4月22日 常用函数
    4月22日 练习题
    PHP正则数组
    PHP基础函数应用
    数据库SQL语句
    高级查询
    mysql
    CSS样式表
    词汇
  • 原文地址:https://www.cnblogs.com/Vincente/p/6236599.html
Copyright © 2011-2022 走看看