# HG changeset patch # User wycc # Date 1287432467 -28800 # Node ID a934ad0c89685042eff291370997ed3213a9434b # Parent 7c4df3c1027f8fe50aa5428df272b91d6a328bac Add the sample app framework. The scene framework will be added latter for multi scene applications. diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/desktop.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/mce/desktop.svg Tue Oct 19 04:07:47 2010 +0800 @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:00-7:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:30-8:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up8:30-9:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up9:30-10:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up10:30-11:30 + + diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/mainmenu.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/mce/mainmenu.js Tue Oct 19 04:07:47 2010 +0800 @@ -0,0 +1,134 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +function MainMenu(app) +{ + var self = this; + app.loadSVG("desktop.svg"); + + this.video = app.get("video"); + this.audio = app.get("audio"); + this.picture = app.get("picture"); + this.setting = app.get("setting"); + this.app = app; + + this.lightbar = app.get("lightbar"); + this.lines = []; + for(i = 0; i < 5; i++) { + var line = app.get("line" + (i + 1)); + this.lines.push(line); + } + this.line=0; + + this.items=[this.video, this.audio, this.picture, this.setting]; + this.item = 0; + + animate.run([new animate.scale(app,this.items[this.item], 1, 1.5)], 0, 0.1); + app.refresh(); + + app.addKeyListener(mbapp.KEY_LEFT, function() { self.key_left();}); + app.addKeyListener(mbapp.KEY_RIGHT, function() { self.key_right();}); + app.addKeyListener(mbapp.KEY_UP, function() {self.key_up();}); + app.addKeyListener(mbapp.KEY_DOWN, function() {self.key_down();}); + app.addKeyListener(mbapp.KEY_ENTER, function() {self.key_enter();}); +} + +MainMenu.prototype.key_left=function () +{ + var old = this.items[this.item]; + this.item = this.item - 1; + if (this.item == -1) { + this.item = 0; + return; + } + + var target = this.items[this.item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(this.app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(this.app, target, 1, 1.5); + animate.run([an], 0, 0.3); +} + +MainMenu.prototype.key_right=function() +{ + var old = this.items[this.item]; + this.item = this.item + 1; + if (this.item == this.items.length) { + this.item = this.item - 1; + return; + } + + var target = this.items[this.item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(this.app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(this.app, target, 1, 1.5); + animate.run([an], 0, 0.3); +} + +MainMenu.prototype.key_up=function() +{ + var old = this.lines[this.line]; + this.line = this.line - 1; + if (this.line == -1) { + this.line = 0; + return; + } + var target = this.lines[this.line]; + var sy = target.center.y - this.lightbar.center.y; + var an = new animate.shift(this.app, this.lightbar, 0, sy); + animate.run([an], 0, 0.3); +} + + +MainMenu.prototype.key_down=function () +{ + var old = this.lines[this.line]; + this.line = this.line + 1; + if (this.line == this.lines.length) { + this.line = this.line - 1; + return; + } + var target = this.lines[this.line]; + var sy = target.center.y - this.lightbar.center.y; + var an = new animate.shift(this.app, this.lightbar, 0, sy); + animate.run([an], 0, 0.3); +} + +MainMenu.prototype.key_enter=function() +{ + var target = this.items[this.item]; + var sx = 500 - target.center.x; + var sy = 220 - target.center.y; + var an = new animate.shift(this.app,target,sx,sy,1); + an.start(); + for(i=0;i 0.5) x = 900; + else x = -500; + if (y > 0.5) y = 900; + else y = -500; + sx = x - this.items[i].center.x; + sy = y - this.items[i].center.y; + an = new animate.shift(this.app,this.items[i], sx, sy); + animate.run([an], 0, 2); + alpha = new animate.alpha(this.app,this.items[i], 0); + animate.run([an], 0, 1); + } +} + +exports.MainMenu=MainMenu; diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/mbmce.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/mce/mbmce.js Tue Oct 19 04:07:47 2010 +0800 @@ -0,0 +1,11 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); +var main=require("./mainmenu"); +app = new mbapp.app(); +scene=new main.MainMenu(app); +app.loop(); diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/music.png Binary file nodejs/examples/mce/music.png has changed diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/photo.png Binary file nodejs/examples/mce/photo.png has changed diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/tool.png Binary file nodejs/examples/mce/tool.png has changed diff -r 7c4df3c1027f -r a934ad0c8968 nodejs/examples/mce/video.png Binary file nodejs/examples/mce/video.png has changed