Mercurial > MadButterfly
annotate nodejs/testsvg.js @ 727:468cd504800c
Rewrite the animation as a module.
author | wycc |
---|---|
date | Tue, 17 Aug 2010 05:15:50 +0800 |
parents | d479f319d7b7 |
children | a843f147c995 |
rev | line source |
---|---|
714 | 1 var svg = require("./svg"); |
716 | 2 var mbapp = require("./mbapp"); |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
3 var sys=require("sys"); |
727 | 4 var animate=require("./animate"); |
714 | 5 |
716 | 6 app = new mbapp.app(); |
7 app.loadSVG("test.svg"); | |
723
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
8 lightbar = app.get("item_lightbar"); |
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
9 item=1; |
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
10 lightbar[5] = app.get("item"+item)[5]; |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
11 |
724 | 12 app.addKeyboardListener(mbapp.EVT_KB_PRESS, function(evt) { |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
13 if (evt.keycode == mbapp.KEY_UP) { |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
14 item = item - 1; |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
15 if (item == 0) item = 1; |
727 | 16 else { |
17 var target = app.get("item"+item); | |
18 var an = new animate.linear(app,lightbar,target[5],0.3); | |
19 an.start(); | |
20 } | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
21 } else if (evt.keycode == mbapp.KEY_DOWN) { |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
22 item = item + 1; |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
23 if (item == 10) { |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
24 item = 9; |
727 | 25 } else { |
26 var target = app.get("item"+item); | |
27 var an = new animate.linear(app,lightbar,target[5],0.3); | |
28 an.start(); | |
29 } | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
30 } |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
31 }); |
716 | 32 app.loop(); |