annotate nodejs/examples/scene/mainmenu.js @ 1529:af8dd27bf450

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