seed r246 - trunk/examples/lightsoff



Author: hortont
Date: Tue Nov 11 12:51:57 2008
New Revision: 246
URL: http://svn.gnome.org/viewvc/seed?rev=246&view=rev

Log:
More Lights Off updates, cleanup, etc.


Modified:
   trunk/examples/lightsoff/board.js
   trunk/examples/lightsoff/light.js
   trunk/examples/lightsoff/main.js

Modified: trunk/examples/lightsoff/board.js
==============================================================================
--- trunk/examples/lightsoff/board.js	(original)
+++ trunk/examples/lightsoff/board.js	Tue Nov 11 12:51:57 2008
@@ -9,7 +9,7 @@
 	var x = light.light_x;
 	var y = light.light_y;
 	
-	var fadeline = new Clutter.Timeline({num_frames:30});
+	var fadeline = new Clutter.Timeline({num_frames: 20});
 	
 	light.flip(fadeline);
 	
@@ -34,6 +34,11 @@
     name: "Board",
     class_init: function(klass, prototype)
     {
+    	prototype.destroy_board = function ()
+    	{
+			this.destroy();
+    	}
+    	
 		prototype.cleared = function ()
 		{
 			for(x in this.lights)
@@ -47,9 +52,8 @@
 		{
 			in_setup = true;
 
-			//var count = Math.round(tiles*5* Math.random());
-			var count = -4;
-
+			var count = Math.round(tiles*5*Math.random());
+			count = -4;//////////////////////////////////////////////
 			var sym = Math.floor(3*Math.random());
 
 			for (q = 0; q < count + 5; ++q)
@@ -86,7 +90,8 @@
 				this.lights[x][y] = new Light();
 				this.lights[x][y].light_x = x;
 				this.lights[x][y].light_y = y;
-				this.lights[x][y].set_position(x * 55 + 5, y * 55 + 5);
+				this.lights[x][y].set_position(x * tile_size + margin + tile_size/2,
+											   y * tile_size + margin + tile_size/2);
 				this.add_actor(this.lights[x][y]);
 			}
 		}

Modified: trunk/examples/lightsoff/light.js
==============================================================================
--- trunk/examples/lightsoff/light.js	(original)
+++ trunk/examples/lightsoff/light.js	Tue Nov 11 12:51:57 2008
@@ -10,8 +10,10 @@
 			if(in_setup)
 			{
 				this.on.opacity = this.state * 255;
-				this.off.opacity = !this.state * 255;
-
+				
+				this.scale_x = this.state?1:.9;
+				this.scale_y = this.state?1:.9;
+				
 				return true;
 			}
 			
@@ -19,11 +21,8 @@
 													 Clutter.sine_inc_func);
 			
 			Clutter.effect_fade(effect, this.on, this.state * 255);
-			Clutter.effect_fade(effect, this.off, !this.state * 255);
-
-			Clutter.effect_rotate(effect, this, Clutter.RotateAxis.x_axis, 360, 25, 25, 25);
-			//Clutter.effect_rotate(effect, this, Clutter.RotateAxis.y_axis, 180, 25, 0, 0);
-
+			Clutter.effect_scale(effect, this, this.state?1:.9, this.state?1:.9);
+			
 			return true;
 		}
     },
@@ -31,18 +30,23 @@
     {
     	this.state = false;
     	
+    	this.scale_x = .9;
+		this.scale_y = .9;
+    	
     	this.on = new Clutter.CloneTexture({parent_texture: on_svg,
 											reactive: true});
 		this.off = new Clutter.CloneTexture({parent_texture: off_svg, 
 											 reactive: true});
 							
 		this.on.opacity = 0.0;
+		
+		this.set_anchor_point(tile_size / 2, tile_size / 2);
 
 		this.on.signal.button_press_event.connect(flip_region, null, this);
 		this.off.signal.button_press_event.connect(flip_region, null, this);
 		
-		this.add_actor(this.on);
 		this.add_actor(this.off);
+		this.add_actor(this.on);
 		
     }};
 

Modified: trunk/examples/lightsoff/main.js
==============================================================================
--- trunk/examples/lightsoff/main.js	(original)
+++ trunk/examples/lightsoff/main.js	Tue Nov 11 12:51:57 2008
@@ -3,6 +3,7 @@
 // images are 50x50
 
 var tiles = 5;
+var margin = 5;
 var in_setup = false;
 
 Seed.import_namespace("Clutter");
@@ -31,20 +32,14 @@
 		return Clutter.ALPHA_MAX_ALPHA*(7.5625 * (time-=(2.625/2.75))*time+.984375);
 }
 
-function destroy_board()
-{
-	this.destroy();
-}
-
 function win_animation()
 {
 	var direction = Math.floor(2 * Math.random());
 	var sign = Math.floor(2 * Math.random()) ? 1 : -1;
-	var offscreen = 55 * tiles + 5;
 
 	var new_board = new Board();
-	new_board.set_position(sign * direction * offscreen, 
-						   sign * (!direction) * offscreen);
+	new_board.set_position(sign * direction * stage.width, 
+						   sign * (!direction) * stage.height);
 	new_board.show();
 	stage.add_actor(new_board);
 	
@@ -53,11 +48,12 @@
 	
 	Clutter.effect_move(effect, new_board, 0, 0);
 	var remove_line = Clutter.effect_move(effect, board, 
-		-(sign)*(direction * offscreen), -(sign)*((!direction) * offscreen));
-
+									-(sign)*(direction * stage.width),
+									-(sign)*((!direction) * stage.height));
+		
 	fadeline.start();
 	
-	remove_line.signal.completed.connect(destroy_board, board);
+	remove_line.signal.completed.connect(board.destroy_board, board);
 	
 	board = new_board;
 }
@@ -65,12 +61,18 @@
 var on_svg = Clutter.Texture.new_from_file("./tim-on.svg");
 var off_svg = Clutter.Texture.new_from_file("./tim-off.svg");
 
+on_svg.filter_quality = Clutter.TextureQuality.high;
+off_svg.filter_quality = Clutter.TextureQuality.high;
+
+var tile_size = on_svg.width + margin;
+
 var black = Clutter.Color._new();
 Clutter.color_parse("Black", black);
 
 var stage = new Clutter.Stage({color: black});
 stage.signal.hide.connect(Clutter.main_quit);
-stage.set_size(55 * tiles + 5, 55 * tiles + 5);
+stage.set_size(tile_size * tiles + margin,
+			   tile_size * tiles + margin);
 
 board = new Board();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]