Mercurial > MadButterfly
comparison nodejs/examples/scene/mainmenu.js @ 1067:7b4e80ab671a openvg
merge from default branch
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 01 Dec 2010 12:25:56 +0800 |
parents | 380464725e75 |
children |
comparison
equal
deleted
inserted
replaced
630:bd18951b51d5 | 1067:7b4e80ab671a |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4 | |
3 var svg = require("svg"); | |
4 var mbapp = require("mbapp"); | |
5 var sys=require("sys"); | |
6 var animate=require("animate"); | |
7 var fs = require("fs"); | |
8 /** | |
9 * We will fetch the EPG file from the server and fetch all images required for the main category from it. | |
10 * If these files are cached, we will not fetch it again. Otherwise, we will fetch them. The EPG class is | |
11 * responsible for the cache management. | |
12 */ | |
13 function MainMenu(app) | |
14 { | |
15 var self = this; | |
16 this.n = 1; | |
17 this.app = app; | |
18 self.init(app); | |
19 } | |
20 MainMenu.prototype.init=function(app) | |
21 { | |
22 var self = this; | |
23 app.loadSVG("mbtest.svg"); | |
24 | |
25 app.addKeyListener(mbapp.KEY_LEFT, function() { self.key_left();}); | |
26 app.addKeyListener(mbapp.KEY_RIGHT, function() { self.key_right();}); | |
27 app.addKeyListener(mbapp.KEY_UP, function() {self.key_up();}); | |
28 app.addKeyListener(mbapp.KEY_DOWN, function() {self.key_down();}); | |
29 app.addKeyListener(mbapp.KEY_ENTER, function() {self.key_enter();}); | |
30 app.changeScene(this.n); | |
31 } | |
32 | |
33 MainMenu.prototype.key_left=function () | |
34 { | |
35 this.n = this.n - 1; | |
36 this.app.changeScene(this.n); | |
37 sys.puts("scene "+this.n); | |
38 } | |
39 | |
40 MainMenu.prototype.key_right=function() | |
41 { | |
42 this.n = this.n + 1; | |
43 this.app.changeScene(this.n); | |
44 sys.puts("scene "+this.n); | |
45 } | |
46 | |
47 MainMenu.prototype.key_up=function() | |
48 { | |
49 } | |
50 | |
51 | |
52 MainMenu.prototype.key_down=function () | |
53 { | |
54 } | |
55 | |
56 MainMenu.prototype.key_enter=function() | |
57 { | |
58 } | |
59 | |
60 exports.MainMenu=MainMenu; |