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