changeset 1442:66609545f7a6

Remove the animation between scene. We need to fix this and put itback latter.
author wycc
date Mon, 11 Apr 2011 13:09:48 +0800
parents 9bd8e814f730
children 2f8e9d66c4c1
files nodejs/examples/mce/mainmenu.js
diffstat 1 files changed, 59 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/examples/mce/mainmenu.js	Mon Apr 11 13:09:11 2011 +0800
+++ b/nodejs/examples/mce/mainmenu.js	Mon Apr 11 13:09:48 2011 +0800
@@ -28,20 +28,30 @@
     var self = this;
     this.items=[];
     for(i=0;i<8;i++) {
-	this.items.push(app.get("cat"+i));
+	this.items.push(app.getComponent("cat"+i));
     }
     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.item = 0;
     this.itemToScene=[0,15,31,47,63,79,95];
 
+    app.addKeyListener(mbapp.KEY_UP, function() { 
+	var target = self.items[self.item].toCoord();
+	sys.puts(target);
+	target.center.move(target.center.x, target.center.y-50);
+	sys.puts(target.center.y);
+	self.app.refresh();
+    });
+    app.addKeyListener(mbapp.KEY_DOWN, function() { 
+	var target = self.items[self.item].toCoord();
+	target.center.move(target.center.x, target.center.y+50);
+	sys.puts("move "+target.center.owner.id);
+	sys.puts(target.center.y);
+	self.app.refresh();
+    });
+
     app.addKeyListener(mbapp.KEY_LEFT, function() { 
         self.item = self.item - 1;
         if (self.item == -1) {
@@ -59,7 +69,15 @@
         self.app.runToScene(self.itemToScene[self.item]);
     });
     app.addKeyListener(mbapp.KEY_ENTER, function() {
-        self.key_enter();
+        try {
+            //self.app.runToScene(self.itemToScene[self.item]);
+            self.key_enter();
+	} catch(e) {
+	    sys.puts("aaa"+e.stack);
+	    for(k in e) {
+	        sys.puts(k+"="+e[k]);
+	    }
+	}
     });
 }
 
@@ -67,33 +85,59 @@
 MainMenu.prototype.key_enter=function() 
 {
     var self = this;
-    var target = this.items[this.item];
+    var target = this.items[this.item].toCoord();
     var an = new animate.scale(this.app, target, 1, 1/1.5);
-    animate.run([an], 0, 0.3,function() {
+
+    this.changePage(self.item);
+    /*
+    animate.run(this.app,[an], 0, 0.3,function() {
         var sx = 259 - target.center.x;
         var sy = 355 - target.center.y;
+	sys.puts("target="+target.id);
 	var an1 = new animate.shift(self.app,target,sx,sy);
-	animate.run([an1],0,1,function() {
+	animate.run(self.app, [an1],0,1,function() {
 	    self.changePage(self.item);
 	});
     });
+    */
+    return;
+    var list=[];
     for(i=0;i<this.items.length;i++) {
 	if (i == this.item) continue;
+	var obj = this.items[i].toCoord();
+	sys.puts(obj);
+	if (obj == undefined) continue;
 	if (i > this.item) {
-	    sx = 1920 - this.items[i].center.x;
+	    sx = 1920 - this.items[i].toCoord().center.x;
 	    sy = 0;
 	} else {
-	    sx =  -this.items[i].center.x*2;
+	    sx =  -this.items[i].toCoord().center.x;
 	    sy = 0;
 	}
 	//alpha = new animate.alpha(this.app,this.items[i], 0);
-	an = new animate.shift(this.app,this.items[i], sx,sy);
-	animate.run([an], 0, 1);
+	sys.puts("111");
+	an = new animate.shift(this.app,this.items[i].toCoord(), sx,sy);
+	list.push(an);
     }
+    animate.run(this.app,list, 0, 1);
+    sys.puts("enter");
 }
 
 MainMenu.prototype.onNextPage=function() {
-    this.app.changeScene(98);
+    sys.puts("aaaaaaaaaaaaaaaaaaaaaa");
+    this.app.changeScene(97);
+    var l = this.app.getComponent('line2');
+    var coord = l.toCoord();
+    if (coord == undefined) return;
+    sys.puts(coord.isdup);
+    sys.puts(coord.id);
+    sys.puts(coord.refid);
+    try {
+        l.set_text('aaaaaaqa');
+    } catch(e) {
+	sys.puts(e);
+    }
+    this.app.refresh();
 }
 MainMenu.prototype.changePage=function(item) {
     this.app.epg.getList(item,this.onNextPage);