Mercurial > MadButterfly
annotate nodejs/mbapp.js @ 721:01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
author | wycc |
---|---|
date | Sun, 15 Aug 2010 19:07:36 +0800 |
parents | 72abb4154936 |
children | 503f3d18248e |
rev | line source |
---|---|
716 | 1 var mbfly = require("mbfly"); |
2 var svg = require("./svg"); | |
3 var mb_rt = new mbfly.mb_rt(":0.0", 720,480); | |
4 var ldr = mbfly.img_ldr_new("."); | |
5 var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0); | |
6 var paint = mb_rt.paint_color_new(1, 1, 1, 1); | |
7 paint.fill(background); | |
8 mb_rt.root.add_shape(background); | |
9 | |
10 app=function() { | |
11 this.mb_rt = mb_rt; | |
12 } | |
13 app.prototype.loadSVG=function(fname) { | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
14 svg.loadSVG(this.mb_rt,this.mb_rt.root,fname); |
716 | 15 } |
16 | |
17 app.prototype.loop=function() { | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
18 this.mb_rt.redraw_all(); |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
19 this.mb_rt.flush(); |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
20 } |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
21 app.prototype.get=function(name) { |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
22 return this.mb_rt.mbnames[name]; |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
23 } |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
24 app.prototype.addKeyboardListener=function(type,f) { |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
25 return this.mb_rt.kbevents.add_event_observer(type,f); |
716 | 26 } |
27 | |
28 exports.app=app; | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
29 |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
30 // Put all key definition here |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
31 exports.KEY_UP=111; |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
32 exports.KEY_DOWN=116; |