private float curTime; public float sumTime = 120; //总时间 void Start() { StartCoroutine("startCountDown"); } public IEnumerator startCountDown() { while (sumTime > 0) { sumTime--; int a, b, c, x; x = (int)sumTime; a = x / 100; b = (x - 100 * a) / 10; c = (x - 100 * a - 10 * b); shuzi1.spriteName = a.ToString() + "k"; shuzi2.spriteName = b.ToString() + "k"; shuzi3.spriteName = c.ToString() + "k"; if (sumTime == 0) { //当游戏时间用完则游戏结束 } //每隔一秒调用一次 yield return new WaitForSeconds(1); } }
同样我工程里图片名为0K-9K
代码很Low,目的是自己以后项目中随时拿过来用,也方便一些新手参考,大神勿喷
浙公网安备 33010602011771号