diff nodejs/animate.js @ 854:eff2f580b536 abs_n_rel_center

Use accessor to return bbox values
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 20 Sep 2010 22:43:43 +0800
parents 3c48a77b75d3
children 88f4916a0691
line wrap: on
line diff
--- a/nodejs/animate.js	Mon Sep 20 22:43:43 2010 +0800
+++ b/nodejs/animate.js	Mon Sep 20 22:43:43 2010 +0800
@@ -11,6 +11,7 @@
 
 function linear_draw() {
     var percent;
+    var x, y;
     
     percent = (Date.now() - this._start_tm) / this.duration;
     if(percent >= 1) {
@@ -20,8 +21,9 @@
 	    delete this.obj.timer;
 	}
     }
-    this.obj.x = (this.targetx-this.startposx)*percent+this.startposx;
-    this.obj.y = (this.targety-this.startposy)*percent+this.startposy;
+    x = (this.targetx-this.startposx)*percent+this.startposx;
+    y = (this.targety-this.startposy)*percent+this.startposy;
+    this.obj.center.move(x, y);
     this.app.refresh();
 }
 
@@ -41,10 +43,10 @@
     this.app = app;
     this.obj = obj;
     this.end = 0;
-    this.targetx = shiftx + obj.x;
-    this.targety = shifty + obj.y;
-    this.startposx = obj.x;
-    this.startposy = obj.y;
+    this.targetx = shiftx + obj.center.x;
+    this.targety = shifty + obj.center.y;
+    this.startposx = obj.center.x;
+    this.startposy = obj.center.y;
     this.duration = duration*1000;
 }