comparison nodejs/testdesktop.js @ 895:3136db0ac01b abs_n_rel_center

Merged from default branch
author Thinker K.F. Li <thinker@branda.to>
date Tue, 28 Sep 2010 17:27:01 +0800
parents 881efcd8a18f 460b2629be30
children
comparison
equal deleted inserted replaced
891:96bc29e948cc 895:3136db0ac01b
25 line=0; 25 line=0;
26 26
27 items=[video, audio, picture, setting]; 27 items=[video, audio, picture, setting];
28 28
29 item = 0; 29 item = 0;
30 an = new animate.scale(app,items[item],1,1.5,0.1); 30
31 an.start(); 31 animate.run([new animate.scale(app,items[item], 1, 1.5)], 0, 0.1);
32 app.refresh(); 32 app.refresh();
33
33 app.addKeyListener(mbapp.KEY_LEFT, function() { 34 app.addKeyListener(mbapp.KEY_LEFT, function() {
34 var old = items[item]; 35 var old = items[item];
35 item = item - 1; 36 item = item - 1;
36 if (item == -1) { 37 if (item == -1) {
37 item = 0; 38 item = 0;
41 var target = items[item]; 42 var target = items[item];
42 43
43 old.bbox.update(); 44 old.bbox.update();
44 target.bbox.update(); 45 target.bbox.update();
45 46
46 var an = new animate.scale(app, old, 1, 1, 0.1); 47 var an = new animate.scale(app, old, 1, 1);
47 an.start(); 48 animate.run([an], 0, 0.1);
48 an = new animate.scale(app, target, 1, 1.5, 0.3); 49 an = new animate.scale(app, target, 1, 1.5);
49 an.start(); 50 animate.run([an], 0, 0.3);
50 }); 51 });
51 52
52 app.addKeyListener(mbapp.KEY_RIGHT, function() { 53 app.addKeyListener(mbapp.KEY_RIGHT, function() {
53 var old = items[item]; 54 var old = items[item];
54 item = item + 1; 55 item = item + 1;
60 var target = items[item]; 61 var target = items[item];
61 62
62 old.bbox.update(); 63 old.bbox.update();
63 target.bbox.update(); 64 target.bbox.update();
64 65
65 var an = new animate.scale(app, old, 1, 1, 0.1); 66 var an = new animate.scale(app, old, 1, 1);
66 an.start(); 67 animate.run([an], 0, 0.1);
67 an = new animate.scale(app, target, 1, 1.5, 0.3); 68 an = new animate.scale(app, target, 1, 1.5);
68 an.start(); 69 animate.run([an], 0, 0.3);
69 }); 70 });
70 71
71 app.addKeyListener(mbapp.KEY_UP, function() { 72 app.addKeyListener(mbapp.KEY_UP, function() {
72 var old = lines[line]; 73 var old = lines[line];
73 line = line - 1; 74 line = line - 1;
76 return; 77 return;
77 } 78 }
78 var target = lines[line]; 79 var target = lines[line];
79 var sy = target.center.y - lightbar.center.y; 80 var sy = target.center.y - lightbar.center.y;
80 sys.puts(sy); 81 sys.puts(sy);
81 var an = new animate.linear(app,lightbar,0,sy,0.3); 82 var an = new animate.shift(app, lightbar, 0, sy);
82 an.start(); 83 animate.run([an], 0, 0.3);
83 }); 84 });
84 app.addKeyListener(mbapp.KEY_DOWN, function() { 85 app.addKeyListener(mbapp.KEY_DOWN, function() {
85 var old = lines[line]; 86 var old = lines[line];
86 line = line + 1; 87 line = line + 1;
87 if (line == lines.length) { 88 if (line == lines.length) {
92 var sy = target.center.y - lightbar.center.y; 93 var sy = target.center.y - lightbar.center.y;
93 sys.puts("line="+line); 94 sys.puts("line="+line);
94 sys.puts("sy="+sy); 95 sys.puts("sy="+sy);
95 sys.puts("target.y="+target.center.y); 96 sys.puts("target.y="+target.center.y);
96 sys.puts("lightbar.y="+lightbar.center.y); 97 sys.puts("lightbar.y="+lightbar.center.y);
97 var an = new animate.linear(app,lightbar,0,sy,0.3); 98 var an = new animate.shift(app, lightbar, 0, sy);
98 an.start(); 99 animate.run([an], 0, 0.3);
99 }); 100 });
100 101
101 app.addKeyListener(mbapp.KEY_ENTER, function() { 102 app.addKeyListener(mbapp.KEY_ENTER, function() {
102 var target = items[item]; 103 var target = items[item];
103 var sx = 500 - target.center.x; 104 var sx = 500 - target.center.x;
104 var sy = 220 - target.center.y; 105 var sy = 220 - target.center.y;
105 sys.puts("target "+sx+','+sy); 106 sys.puts("target "+sx+','+sy);
106 var an = new animate.linear(app,target,sx,sy,1); 107 var an = new animate.shift(app,target,sx,sy,1);
107 an.start(); 108 an.start();
108 for(i=0;i<items.length;i++) { 109 for(i=0;i<items.length;i++) {
109 if (i == item) continue; 110 if (i == item) continue;
110 var x = Math.random(); 111 var x = Math.random();
111 var y = Math.random(); 112 var y = Math.random();
113 else x = -500; 114 else x = -500;
114 if (y > 0.5) y = 900; 115 if (y > 0.5) y = 900;
115 else y = -500; 116 else y = -500;
116 sx = x - items[i].center.x; 117 sx = x - items[i].center.x;
117 sy = y - items[i].center.y; 118 sy = y - items[i].center.y;
118 an = new animate.linear(app,items[i], sx,sy,2); 119 an = new animate.shift(app,items[i], sx, sy);
119 an.start(); 120 animate.run([an], 0, 2);
120 alpha = new animate.alpha(app,items[i],0, 1); 121 alpha = new animate.alpha(app,items[i], 0);
121 alpha.start(); 122 animate.run([an], 0, 1);
122 } 123 }
123 }); 124 });
124 125
125 app.loop(); 126 app.loop();