Mercurial > MadButterfly
annotate nodejs/testsvg.js @ 730:e77ae2d23245
Add addKeyListener to handle key input.
author | wycc |
---|---|
date | Fri, 20 Aug 2010 07:21:24 +0800 |
parents | 299ed9319dc6 |
children | 6879aa403306 |
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 |
730 | 12 app.addKeyListener(mbapp.KEY_UP, function() { |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
13 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
|
14 if (item == 0) item = 1; |
727 | 15 else { |
16 var target = app.get("item"+item); | |
728 | 17 var an = new animate.linear(app,lightbar,target[2],target[5],0.3); |
727 | 18 an.start(); |
19 } | |
730 | 20 }); |
21 | |
22 app.addKeyListener(mbapp.KEY_DOWN, function() { | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
23 item = item + 1; |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
24 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
|
25 item = 9; |
727 | 26 } else { |
27 var target = app.get("item"+item); | |
728 | 28 var an = new animate.linear(app,lightbar,target[2],target[5],0.3); |
727 | 29 an.start(); |
30 } | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
31 }); |
730 | 32 |
716 | 33 app.loop(); |