Mercurial > MadButterfly
comparison nodejs/testdesktop.js @ 892:23dffb564ace
Implemnet new animation framework as the WIKI.
author | wycc |
---|---|
date | Mon, 27 Sep 2010 22:37:37 +0800 |
parents | d1c98eb474e1 |
children | cad38ddb1253 |
comparison
equal
deleted
inserted
replaced
872:bcc63b20d5c6 | 892:23dffb564ace |
---|---|
15 picture = app.get("picture"); | 15 picture = app.get("picture"); |
16 setting = app.get("setting"); | 16 setting = app.get("setting"); |
17 | 17 |
18 lightbar = app.get("lightbar"); | 18 lightbar = app.get("lightbar"); |
19 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; | 19 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; |
20 for(i=0;i<lines.length;i++) { | |
21 sys.puts("["+i+"]="+lines[i].y); | |
22 } | |
23 line=0; | 20 line=0; |
24 | 21 |
25 items=[video,audio,picture,setting]; | 22 items=[video,audio,picture,setting]; |
26 item = 0; | 23 item = 0; |
27 an = new animate.scale(app,items[item],1,1.5,0.1); | 24 |
28 an.start(); | 25 animate.run([new animate.scale(app,items[item],1,1.5)],0,0.1); |
29 app.refresh(); | 26 app.refresh(); |
27 | |
30 app.addKeyListener(mbapp.KEY_LEFT, function() { | 28 app.addKeyListener(mbapp.KEY_LEFT, function() { |
31 var old = items[item]; | 29 var old = items[item]; |
32 item = item - 1; | 30 item = item - 1; |
33 if (item == -1) { | 31 if (item == -1) { |
34 item = 0; | 32 item = 0; |
35 return; | 33 return; |
36 } | 34 } |
37 var target = items[item]; | 35 var target = items[item]; |
38 var an = new animate.scale(app,old,1,1,0.1); | 36 animate.run([new animate.scale(app,old,1,1)],0,0.1); |
39 an.start(); | 37 animate.run([new animate.scale(app,target,1,1.5)],0,0.3); |
40 an = new animate.scale(app,target,1,1.5,0.3); | |
41 an.start(); | |
42 }); | 38 }); |
43 | 39 |
44 app.addKeyListener(mbapp.KEY_RIGHT, function() { | 40 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
45 var old = items[item]; | 41 var old = items[item]; |
46 item = item + 1; | 42 item = item + 1; |
47 if (item == items.length) { | 43 if (item == items.length) { |
48 item = item - 1; | 44 item = item - 1; |
49 return; | 45 return; |
50 } | 46 } |
51 var target = items[item]; | 47 var target = items[item]; |
52 var an = new animate.scale(app,old,1,1,0.1); | 48 animate.run([new animate.scale(app,old,1,1)],0,0.1); |
53 an.start(); | 49 animate.run([new animate.scale(app,target,1,1.5)],0,0.3); |
54 an = new animate.scale(app,target,1,1.5,0.3); | |
55 an.start(); | |
56 }); | 50 }); |
57 | 51 |
58 app.addKeyListener(mbapp.KEY_UP, function() { | 52 app.addKeyListener(mbapp.KEY_UP, function() { |
59 var old = lines[line]; | 53 var old = lines[line]; |
60 line = line - 1; | 54 line = line - 1; |
63 return; | 57 return; |
64 } | 58 } |
65 var target = lines[line]; | 59 var target = lines[line]; |
66 var sy = target.y-lightbar.y; | 60 var sy = target.y-lightbar.y; |
67 sys.puts(sy); | 61 sys.puts(sy); |
68 var an = new animate.linear(app,lightbar,0,sy,0.3); | 62 animate.run([new animate.shift(app,lightbar,0,sy)],0,0.3); |
69 an.start(); | |
70 }); | 63 }); |
71 app.addKeyListener(mbapp.KEY_DOWN, function() { | 64 app.addKeyListener(mbapp.KEY_DOWN, function() { |
72 var old = lines[line]; | 65 var old = lines[line]; |
73 line = line + 1; | 66 line = line + 1; |
74 if (line == lines.length) { | 67 if (line == lines.length) { |
79 var sy = target.y-lightbar.y; | 72 var sy = target.y-lightbar.y; |
80 sys.puts("line="+line); | 73 sys.puts("line="+line); |
81 sys.puts("sy="+sy); | 74 sys.puts("sy="+sy); |
82 sys.puts("target.y="+target.y); | 75 sys.puts("target.y="+target.y); |
83 sys.puts("lightbar.y="+lightbar.y); | 76 sys.puts("lightbar.y="+lightbar.y); |
84 var an = new animate.linear(app,lightbar,0,sy,0.3); | 77 animate.run([new animate.shift(app,lightbar,0,sy)],0,0.3); |
85 an.start(); | |
86 }); | 78 }); |
87 | 79 |
88 app.addKeyListener(mbapp.KEY_ENTER, function() { | 80 app.addKeyListener(mbapp.KEY_ENTER, function() { |
89 var target = items[item]; | 81 var target = items[item]; |
90 var sx = 500-target.x; | 82 var sx = 500-target.x; |
91 var sy = 220-target.y; | 83 var sy = 220-target.y; |
92 sys.puts("target "+sx+','+sy); | 84 sys.puts("target "+sx+','+sy); |
93 var an = new animate.linear(app,target,sx,sy,1); | 85 animate.run([new animate.shift(app,target,sx,sy)],0,1); |
94 an.start(); | |
95 for(i=0;i<items.length;i++) { | 86 for(i=0;i<items.length;i++) { |
96 if (i == item) continue; | 87 if (i == item) continue; |
97 var x = Math.random(); | 88 var x = Math.random(); |
98 var y = Math.random(); | 89 var y = Math.random(); |
99 if (x > 0.5) x = 900; | 90 if (x > 0.5) x = 900; |
100 else x = -500; | 91 else x = -500; |
101 if (y > 0.5) y = 900; | 92 if (y > 0.5) y = 900; |
102 else y = -500; | 93 else y = -500; |
103 sx = x-items[i].x; | 94 sx = x-items[i].x; |
104 sy = y-items[i].y; | 95 sy = y-items[i].y; |
105 an = new animate.linear(app,items[i], sx,sy,2); | 96 animate.run([new animate.shift(app,items[i], sx,sy)],0,2); |
106 an.start(); | 97 animate.run([new animate.alpha(app,items[i],0)],0, 1); |
107 alpha = new animate.alpha(app,items[i],0, 1); | |
108 alpha.start(); | |
109 } | 98 } |
110 }); | 99 }); |
111 | 100 |
112 app.loop(); | 101 app.loop(); |