view 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
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.keycode == 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[5],0.3);
		    an.start();
		}
	} else if (evt.keycode == 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[5],0.3);
		    an.start();
		}
	}
});
app.loop();