為什么不直接使用curShowTimeSeconds = getCurShowTimeSeconds()
在update里為什么還要這么麻煩弄一個(gè)nextShowTimeSeconds,直接curShowTimeSeconds = getCurShowTimeSeconds()不可以嗎?如果要做更新之前的操作,也可以在curShowTimeSeconds = getCurShowTimeSeconds()之前做?。?/p>
在update里為什么還要這么麻煩弄一個(gè)nextShowTimeSeconds,直接curShowTimeSeconds = getCurShowTimeSeconds()不可以嗎?如果要做更新之前的操作,也可以在curShowTimeSeconds = getCurShowTimeSeconds()之前做?。?/p>
舉報(bào)
2017-03-03
curShowTimeSeconds = getCurShowTimeSeconds()表示curShowTimeSeconds一直都在獲取動(dòng)態(tài)值,但我們要生成與與當(dāng)前一樣的彩色小球,實(shí)際上是獲取一個(gè)curShowTimeSeconds靜態(tài)值,而且隨著getCurShowTimeSeconds()變化,這個(gè)獲取到的curShowTimeSeconds變成了上一秒時(shí)間(靜態(tài)的)。
所以根本原因是:我們要?jiǎng)討B(tài)生成彩色小球。
?方法就是:通過添加nextShowTimeSeconds = getCurShowTimeSeconds(),使nextShowTimeSeconds變成動(dòng)態(tài)的當(dāng)前秒數(shù),并通過動(dòng)態(tài)的nextShowTimeSeconds與靜態(tài)的curShowTimeSeconds比較(源碼52-72行),才能用addBalls動(dòng)態(tài)獲得彩色小球。