今天写了一个赛车能量条,但是美术给的图片有点问题,只能将能量条的fillAmount从1减到0,正好对应能量从0加到满,那么怎么对应上是个问题,首先计算,能量条满值是2.5,1/2.5f代表能量条从1减到0等比减少的能量,2.5f减去每次的增量,然后乘以能量条的增量:energy.GetComponent<Image>().fillAmount = 1/2.5f * (2.5f - Global.Ins.gameLayer.speed);在update里面速度没增长一点,能量就随之增长,满值为1.
energy.GetComponent<Image>().fillAmount = 0.4f * (2.5f - Global.Ins.gameLayer.speed);
网友评论