Mercurial > MadButterfly
comparison nodejs/mbapp.js @ 1392:cd5fb45bc247
Check if the scenes is defined. Disable the changeScene function if the scenes is not defined for the pure MB program.
author | wycc |
---|---|
date | Sun, 27 Mar 2011 08:27:03 +0800 |
parents | ff8122c59648 |
children | a5672125e515 |
comparison
equal
deleted
inserted
replaced
1391:ff8122c59648 | 1392:cd5fb45bc247 |
---|---|
190 } | 190 } |
191 | 191 |
192 app.prototype.generateScaleTweenObject=function(coord,src,dest,p) { | 192 app.prototype.generateScaleTweenObject=function(coord,src,dest,p) { |
193 sys.puts("src=["+src.sx+","+src.sy+","+src.r+","+src.tx+","+src.ty); | 193 sys.puts("src=["+src.sx+","+src.sy+","+src.r+","+src.tx+","+src.ty); |
194 sys.puts("dest=["+dest.sx+","+dest.sy+","+dest.r+","+dest.tx+","+dest.ty); | 194 sys.puts("dest=["+dest.sx+","+dest.sy+","+dest.r+","+dest.tx+","+dest.ty); |
195 if (src == null) return; | |
196 sys.puts("src.center="+src.center); | |
195 var p1 = 1-p; | 197 var p1 = 1-p; |
198 var x1 = src.center.x; | |
199 var y1 = src.center.y; | |
196 var sx = src.sx*p+dest.sx*p1; | 200 var sx = src.sx*p+dest.sx*p1; |
197 var sy = src.sy*p+dest.sy*p1; | 201 var sy = src.sy*p+dest.sy*p1; |
198 var r = src.r*p+dest.r*p1; | 202 var r = src.r*p+dest.r*p1; |
199 var tx = src.tx*p+dest.tx*p1; | 203 var tx = src.tx*p+dest.tx*p1-src.tx; |
200 var ty = src.ty*p+dest.ty*p1; | 204 var ty = src.ty*p+dest.ty*p1-src.ty; |
201 var mt = [1, 0, -src.tx, 0, 1, -src.ty]; | 205 var mt = [1, 0, -x1, 0, 1, -y1]; |
202 var opacity; | 206 var opacity; |
203 var ms; | 207 var ms; |
204 | 208 |
205 opacity = src.opacity*p + dest.opacity*p1; | 209 opacity = src.opacity*p + dest.opacity*p1; |
206 coord.opacity = opacity; | 210 coord.opacity = opacity; |
209 m = mt; | 213 m = mt; |
210 } else { | 214 } else { |
211 ms= [Math.cos(r), Math.sin(r),0,-Math.sin(r), Math.cos(r),0]; | 215 ms= [Math.cos(r), Math.sin(r),0,-Math.sin(r), Math.cos(r),0]; |
212 m = mul(ms,mt); | 216 m = mul(ms,mt); |
213 } | 217 } |
218 sys.puts("x1="+x1); | |
219 sys.puts("y1="+y1); | |
214 m = mul([sx,0,0,0,sy,0],m); | 220 m = mul([sx,0,0,0,sy,0],m); |
221 m = mul([1,0,x1,0,1,y1],m); | |
215 m = mul([1,0,tx,0,1,ty],m); | 222 m = mul([1,0,tx,0,1,ty],m); |
216 m[2] = -m[2]; | 223 //m[2] = -m[2]; |
217 coord[0] = m[0]; | 224 coord[0] = m[0]; |
218 coord[1] = m[1]; | 225 coord[1] = m[1]; |
219 coord[2] = m[2]; | 226 coord[2] = m[2]; |
220 coord[3] = m[3]; | 227 coord[3] = m[3]; |
221 coord[4] = m[4]; | 228 coord[4] = m[4]; |
222 coord[5] = m[5]; | 229 coord[5] = m[5]; |
223 //sys.puts(coord); | 230 //sys.puts(coord); |
224 //sys.puts("p="+p+" "+m[0]+","+m[1]+","+m[2]+","+m[3]+","+m[4]+","+m[5]); | 231 sys.puts("p="+p+" "+m[0]+","+m[1]+","+m[2]+","+m[3]+","+m[4]+","+m[5]); |
225 } | 232 } |
226 | 233 |
227 app.prototype.changeScene=function(s) { | 234 app.prototype.changeScene=function(s) { |
228 var nth; | 235 var nth; |
229 sys.puts(s); | 236 sys.puts(s); |
236 if (nth == -1) return; | 243 if (nth == -1) return; |
237 } | 244 } |
238 sys.puts("goto to scene "+nth); | 245 sys.puts("goto to scene "+nth); |
239 this.currentScene = nth; | 246 this.currentScene = nth; |
240 var scenes = this.svg.scenes; | 247 var scenes = this.svg.scenes; |
248 if (scenes == null) return; | |
241 for(i=0;i<scenes.length-1;i++) { | 249 for(i=0;i<scenes.length-1;i++) { |
242 try { | 250 try { |
243 if (nth >=scenes[i].start && nth <=scenes[i].end) { | 251 if (nth >=scenes[i].start && nth <=scenes[i].end) { |
244 sys.puts("find"); | 252 sys.puts("find"); |
245 if (scenes[i].type == 'normal' || i == scenes.length-1) { | 253 if (scenes[i].type == 'normal' || i == scenes.length-1) { |