seed r835 - trunk/examples/same-seed



Author: hortont
Date: Tue Feb  3 09:53:25 2009
New Revision: 835
URL: http://svn.gnome.org/viewvc/seed?rev=835&view=rev

Log:
Better animation, etc.


Modified:
   trunk/examples/same-seed/board.js
   trunk/examples/same-seed/light.js
   trunk/examples/same-seed/main.js

Modified: trunk/examples/same-seed/board.js
==============================================================================
--- trunk/examples/same-seed/board.js	(original)
+++ trunk/examples/same-seed/board.js	Tue Feb  3 09:53:25 2009
@@ -17,6 +17,14 @@
 		var lights = new Array();
 		var all_lights = new Array();
 		var cl, oldpicked;
+		var animating = false;
+		
+		function done_animating()
+		{
+			animating = false;
+			
+			return false;
+		}
 		
 		function _light_connected_lights(li)
 		{
@@ -33,6 +41,9 @@
 			
 			var con = [li];
 			
+			while(GLib.main_context_pending())
+				GLib.main_context_iteration();
+			
 			// Do all of the concatenation together for performance
 			
 			var a = [], b = [], c = [], d = [];
@@ -101,19 +112,25 @@
 		
 		var mouse_moved = function (actor, event)
 		{
+			if(animating)
+				return false;
+			
 			var picked = stage.get_actor_at_pos(event.motion.x,
 												event.motion.y).get_parent();
 			
 			if(picked == oldpicked)
-				return;
+				return false;
+			else
+				oldpicked = picked;
+			
+			cl = light_connected_lights(picked);
 			
 			for(var i in all_lights)
 			{
-				all_lights[i].opacity = 180;
+				if(!all_lights[i].get_closed())
+					all_lights[i].opacity = 180;
 			}
 			
-			cl = light_connected_lights(picked);
-			
 			if(cl.length < 2)
 				return false;
 			
@@ -197,12 +214,38 @@
 					li.set_light_x(real_x);
 					li.set_light_y(parseInt(y,10));
 					
-					li.anim = li.animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, 500,
+					if(li.get_closed())
+					{
+						li.on.anim = li.on.animate(Clutter.AnimationMode.LINEAR,500,
+						{
+							height: [GObject.TYPE_INT, tile_size * 2],
+							width: [GObject.TYPE_INT, tile_size * 2],
+							x: [GObject.TYPE_INT, -tile_size/2],
+							y: [GObject.TYPE_INT, -tile_size/2]
+						});
+						li.on.anim.timeline.start();
+						
+						li.on.anim.timeline.signal.completed.connect(li.hide_light, li);
+						
+						li.anim = li.animate(Clutter.AnimationMode.LINEAR,500,
+						{
+							opacity: [GObject.TYPE_UCHAR, 0]
+						});
+						li.anim.timeline.start();
+					}
+					else
 					{
-						x: [GObject.TYPE_INT, real_x * tile_size + offset],
-						y: [GObject.TYPE_INT, (tiles_h - y - 1) * tile_size + offset]
-					});
-					li.anim.timeline.start();
+						animating = true;
+						
+						li.anim = li.animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, 500,
+						{
+							x: [GObject.TYPE_INT, real_x * tile_size + offset],
+							y: [GObject.TYPE_INT, (tiles_h - y - 1) * tile_size + offset]
+						});
+						li.anim.timeline.start();
+						
+						li.anim.timeline.signal.completed.connect(done_animating);
+					}
 					
 					if(!li.get_closed())
 						empty_col = false;

Modified: trunk/examples/same-seed/light.js
==============================================================================
--- trunk/examples/same-seed/light.js	(original)
+++ trunk/examples/same-seed/light.js	Tue Feb  3 09:53:25 2009
@@ -1,4 +1,4 @@
-var tile_svg_size = 100;
+var tile_svg_size = 50;
 
 function load_svg(file)
 {
@@ -45,7 +45,14 @@
 		{
 			closed = true;
 			
-			this.hide();
+			//this.hide();
+		}
+		
+		this.hide_light = function (timeline, light)
+		{
+			light.hide();
+			
+			return false;
 		}
 		
 		this.set_light_x = function (new_x)

Modified: trunk/examples/same-seed/main.js
==============================================================================
--- trunk/examples/same-seed/main.js	(original)
+++ trunk/examples/same-seed/main.js	Tue Feb  3 09:53:25 2009
@@ -24,6 +24,8 @@
 var black = new Clutter.Color();
 Clutter.color_parse("Black", black);
 
+Clutter.set_motion_events_frequency(10);
+
 var stage = new Clutter.Stage();
 
 stage.title = "Same Seed";



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