Mercurial > MadButterfly
changeset 728:a843f147c995
Add Y coordiante in the linear animation.
author | wycc |
---|---|
date | Tue, 17 Aug 2010 08:31:24 +0800 |
parents | 468cd504800c |
children | 299ed9319dc6 |
files | nodejs/animate.js nodejs/testsvg.js |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/animate.js Tue Aug 17 05:15:50 2010 +0800 +++ b/nodejs/animate.js Tue Aug 17 08:31:24 2010 +0800 @@ -4,7 +4,8 @@ if (this.end == 1) return; var percent = (Date.now() - this.starttime)/this.duration; if (percent > 1) percent = 1; - this.obj[5] = (this.target-this.startpos)*percent+this.startpos; + this.obj[2] = (this.targetx-this.startposx)*percent+this.startposx; + this.obj[5] = (this.targety-this.startposy)*percent+this.startposy; this.app.refresh(); var self = this; if (percent < 1) { @@ -14,7 +15,7 @@ this.app.refresh(); this.obj.animated_linear = null; } -function linear(app,obj,target,duration) { +function linear(app,obj,targetx,targety,duration) { try { if (obj.animated_linear) { obj[5] = obj.animated_linear.target; @@ -28,8 +29,10 @@ this.obj = obj; this.end = 0; this.starttime = Date.now(); - this.startpos = obj[5]; - this.target = target; + this.startposx = obj[2]; + this.startposy = obj[5]; + this.targetx = targetx; + this.targety = targety; this.duration = duration*1000; }
--- a/nodejs/testsvg.js Tue Aug 17 05:15:50 2010 +0800 +++ b/nodejs/testsvg.js Tue Aug 17 08:31:24 2010 +0800 @@ -15,7 +15,7 @@ if (item == 0) item = 1; else { var target = app.get("item"+item); - var an = new animate.linear(app,lightbar,target[5],0.3); + var an = new animate.linear(app,lightbar,target[2],target[5],0.3); an.start(); } } else if (evt.keycode == mbapp.KEY_DOWN) { @@ -24,7 +24,7 @@ item = 9; } else { var target = app.get("item"+item); - var an = new animate.linear(app,lightbar,target[5],0.3); + var an = new animate.linear(app,lightbar,target[2],target[5],0.3); an.start(); } }