seed r255 - trunk/examples/lightsoff
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r255 - trunk/examples/lightsoff
- Date: Wed, 12 Nov 2008 08:39:17 +0000 (UTC)
Author: hortont
Date: Wed Nov 12 08:39:17 2008
New Revision: 255
URL: http://svn.gnome.org/viewvc/seed?rev=255&view=rev
Log:
Add scoring!
Modified:
trunk/examples/lightsoff/board.js
trunk/examples/lightsoff/main.js
trunk/examples/lightsoff/score.js
Modified: trunk/examples/lightsoff/board.js
==============================================================================
--- trunk/examples/lightsoff/board.js (original)
+++ trunk/examples/lightsoff/board.js Wed Nov 12 08:39:17 2008
@@ -1,7 +1,10 @@
function check_won (timeline, light)
{
if(light.get_parent().cleared() && !in_setup)
+ {
+ score.increment_value(100);
win_animation();
+ }
}
function flip_region (act, evt, light)
@@ -34,11 +37,6 @@
name: "Board",
class_init: function(klass, prototype)
{
- prototype.destroy_board = function ()
- {
- this.destroy();
- }
-
prototype.cleared = function ()
{
for(x in this.lights)
Modified: trunk/examples/lightsoff/main.js
==============================================================================
--- trunk/examples/lightsoff/main.js (original)
+++ trunk/examples/lightsoff/main.js Wed Nov 12 08:39:17 2008
@@ -49,14 +49,12 @@
var effect = Clutter.EffectTemplate._new(fadeline, alpha_func);
Clutter.effect_move(effect, new_board, 0, 0);
- var remove_line = Clutter.effect_move(effect, board,
- -(sign)*(direction * stage.width),
- -(sign)*((!direction) * stage.height));
+ Clutter.effect_move(effect, board,
+ -(sign)*(direction * stage.width),
+ -(sign)*((!direction) * stage.height));
fadeline.start();
- remove_line.signal.completed.connect(board.destroy_board, board);
-
board = new_board;
}
Modified: trunk/examples/lightsoff/score.js
==============================================================================
--- trunk/examples/lightsoff/score.js (original)
+++ trunk/examples/lightsoff/score.js Wed Nov 12 08:39:17 2008
@@ -1,13 +1,47 @@
-function destroy_old()
-{
- this.destroy();
-}
-
ScoreType = {
parent: Clutter.Group.type,
name: "Score",
class_init: function(klass, prototype)
{
+ prototype.increment_value = function (val)
+ {
+ var current_val = this.value;
+ var max_val = this.value + val;
+ for(var i = this.value; i <= max_val; i += 5)
+ {
+ Seed.setTimeout("score.magic_value("+i+");",5*(i - current_val) + 100);
+ }
+ }
+
+ prototype.magic_value = function (val)
+ {
+ this.value = val;
+
+ var old_set = this.current_set;
+
+ this.current_set = new Clutter.Group();
+ //this.current_set.opacity = 0;
+
+ var val_s = Seed.sprintf("% 5d",val);
+
+ for(var i = 0; i < val_s.length; i++)
+ {
+ var texture = this.num_textures[val_s[i]];
+
+ if(val_s[i] == ' ')
+ texture = null;
+
+ var num = new Clutter.CloneTexture({parent_texture:texture});
+ num.set_position(56*i-10,3);
+ num.set_size(97,97);
+ this.current_set.add_actor(num);
+ }
+
+ this.add_actor(this.current_set);
+ old_set.destroy();
+ this.bkg_top.raise_top();
+ }
+
prototype.set_value = function (val)
{
this.value = val;
@@ -34,16 +68,15 @@
this.add_actor(this.current_set);
- var fadeline = new Clutter.Timeline({num_frames:30});
+ var fadeline = new Clutter.Timeline({num_frames:60});
var effect = Clutter.EffectTemplate._new(fadeline, Clutter.sine_inc_func);
Clutter.effect_fade(effect, this.current_set, 255);
if(old_set)
{
var deleteline = Clutter.effect_fade(effect, old_set, 0);
- Clutter.effect_scale(effect, old_set, 2, 2);
+ //Clutter.effect_scale(effect, old_set, 2, 2);
- deleteline.signal.completed.connect(destroy_old, old_set);
}
fadeline.start();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]