想了很久,終于想通了關(guān)于curShowTimeSeconds(實際顯示的剩余時間)的值的問題。
關(guān)鍵在于下面這段代碼
curShowTimeSeconds = getCurrentShowTimeSeconds()
? ? setInterval(
? ? ? ? function(){
? ? ? ? ? ? render( context );
? ? ? ? ? ? update();
? ? ? ? }
? ? ? ? ,
? ? ? ? 50
? ? );
}
由于curShowTimeSeconds = getCurrentShowTimeSeconds()在整個需要每50毫秒刷新的
setInterval()方法的外部,因此實際上來說,curShowTimeSeconds只有第一次得到的賦值是直接從系統(tǒng)時間獲得的與endTime時間的差值而來的。
而以后每次得到的值只能是nextSeconds賦值給它的!!因為curShowTimeSeconds = getCurrentShowTimeSeconds()”這句話在方法外部,每50ms的刷新刷不到它!自然也不能通過getCurrentShowTimeSeconds()函數(shù)來獲得新值!
然而只有nextSeconds是屬于setInterval()方法的內(nèi)部的,可以每次通過刷新來得到當前系統(tǒng)時間,從而與已有的curShowTimeSeconds 比較來決定是否賦新值給它!
2016-04-18
實際上不比較值都可以完成刷新的操作誒。。。