Mercurial > MadButterfly
view nodejs/testsvg.js @ 729:299ed9319dc6
Use key symbols instead of keycodes.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 17 Aug 2010 10:36:36 +0800 |
parents | a843f147c995 |
children | e77ae2d23245 |
line wrap: on
line source
var svg = require("./svg"); var mbapp = require("./mbapp"); var sys=require("sys"); var animate=require("./animate"); app = new mbapp.app(); app.loadSVG("test.svg"); lightbar = app.get("item_lightbar"); item=1; lightbar[5] = app.get("item"+item)[5]; app.addKeyboardListener(mbapp.EVT_KB_PRESS, function(evt) { if (evt.sym == mbapp.KEY_UP) { item = item - 1; if (item == 0) item = 1; else { var target = app.get("item"+item); var an = new animate.linear(app,lightbar,target[2],target[5],0.3); an.start(); } } else if (evt.sym == mbapp.KEY_DOWN) { item = item + 1; if (item == 10) { item = 9; } else { var target = app.get("item"+item); var an = new animate.linear(app,lightbar,target[2],target[5],0.3); an.start(); } } }); app.loop();