# HG changeset patch # User wycc # Date 1302293282 -28800 # Node ID 5487aaf6f863ddf2b193db3f9eb12f3c36970be2 # Parent 13e126941bdd8fbcb796deaf70bdab6c5a7edc36 Change the algorithm to determine the gap between frames so that the go back can be calculated correctly. diff -r 13e126941bdd -r 5487aaf6f863 nodejs/mbapp.js --- a/nodejs/mbapp.js Sat Apr 09 03:41:03 2011 +0800 +++ b/nodejs/mbapp.js Sat Apr 09 04:08:02 2011 +0800 @@ -124,7 +124,7 @@ this.keymap={}; this.onKeyPress = null; this.svg = new svg.loadSVG(this.mb_rt,this.mb_rt.root,null); - this.frame_interval = 1000/30; // 12 frame per second + this.frame_interval = 1000/12; // 12 frame per second this.timer = null; this._time = Date.now(); this._componentmanager = new component.ComponentManager(this); @@ -386,20 +386,17 @@ if (nextframe < this.targetScene) nextframe = this.targetScene; } + this.changeScene(nextframe); if (nextframe != this.targetScene) { - var timegap = (nextframe-this.startScene)*this.skipdir*this.frame_interval+this.starttime - Date.now(); - sys.puts("goto "+timegap); - if (timegap <200) { - timegap = 0; - } else { - } + var timegap = this.frame_interval - (Date.now()-now); + if (timegap < 0) timegap = 0; + this.timer = setTimeout(function() { self.skipFrame() - }, timegap); + }, timegap ); } else { this.timer = null; } - this.changeScene(nextframe); now = Date.now(); this.ts("goto end"); }