[gnome-games] Lights Off: Many changes to match internal Clutter changes
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] Lights Off: Many changes to match internal Clutter changes
- Date: Thu, 16 Jul 2009 22:28:10 +0000 (UTC)
commit 097b02edb25bea8d69925fa6a70bb2994f5a86d5
Author: Tim Horton <hortont svn gnome org>
Date: Fri Jun 5 20:12:15 2009 -0400
Lights Off: Many changes to match internal Clutter changes
Right now, we have a hack (in seed/patches) to fix double-animation bug, and this patch includes fixes to:
1) Don't animate before you're visible
2) (HACK) can't clone things that aren't visible
^ Clutter source code says this is possible, but I have yet to determine how to do it
3) Some raise/lower fixes (still missing some)
4) create the board at the right time (no more precreating, for now)
lightsoff/Board.js.in | 21 +++++++++++++++++--
lightsoff/Game.js.in | 12 +++++++---
lightsoff/Light.js.in | 38 +++++++++++++++++++++++------------
lightsoff/main.js.in | 2 +
lightsoff/themes/tango/theme.js | 23 ---------------------
lightsoff/themes/tango/theme.js.in | 20 ++++++++++++++++++
lightsoff/themes/up/theme.js.in | 20 ++++++++++++++++++
7 files changed, 93 insertions(+), 43 deletions(-)
---
diff --git a/lightsoff/Board.js.in b/lightsoff/Board.js.in
index 55d10dc..0e222a6 100644
--- a/lightsoff/Board.js.in
+++ b/lightsoff/Board.js.in
@@ -18,6 +18,7 @@ BoardView = new GType({
var self = this;
var playable = true;
var lights = [];
+ var loading_level = false;
// Create a two-dimensional array of 'tiles*tiles' lights,
// connect to their clicked signals, and display them.
@@ -47,8 +48,13 @@ BoardView = new GType({
if(!playable)
return;
- var timeline = new Clutter.Timeline({duration: 300});
- timeline.signal.completed.connect(check_won);
+ var timeline = null;
+
+ if(!loading_level)
+ {
+ timeline = new Clutter.Timeline({duration: 300});
+ timeline.signal.completed.connect(check_won);
+ }
if(x + 1 < tiles)
lights[x + 1][y].toggle(timeline);
@@ -61,7 +67,8 @@ BoardView = new GType({
lights[x][y].toggle(timeline);
- timeline.start();
+ if(!loading_level)
+ timeline.start();
}
// Check if the game was won; if so, emit the game_won signal
@@ -101,6 +108,12 @@ BoardView = new GType({
// symmetry for some levels.
this.load_level = function(level)
{
+ loading_level = true;
+
+ for(var x = 0; x < tiles; x++)
+ for(var y = 0; y < tiles; y++)
+ lights[x][y].set_state(0, 0);
+
GLib.random_set_seed(level);
do
@@ -129,6 +142,8 @@ BoardView = new GType({
}
}
while(cleared());
+
+ loading_level = false;
}
this.set_playable = function(p)
diff --git a/lightsoff/Game.js.in b/lightsoff/Game.js.in
index 0301851..c858ebf 100644
--- a/lightsoff/Game.js.in
+++ b/lightsoff/Game.js.in
@@ -36,7 +36,6 @@ GameView = new GType({
new_board_view.set_playable(false);
self.add_actor(new_board_view);
new_board_view.lower_bottom();
-
}
// The boards have finished transitioning; delete the old one!
@@ -46,8 +45,6 @@ GameView = new GType({
board_view = new_board_view;
board_view.set_playable(true);
timeline = 0;
-
- create_next_board();
}
// The player won the game; create a new board, update the level count,
@@ -72,8 +69,10 @@ GameView = new GType({
last_sign = sign;
timeline = new Clutter.Timeline({duration: 1500});
-
+
+ create_next_board();
new_board_view.show();
+
new_board_view.animate_in(direction, sign, timeline);
board_view.animate_out(direction, sign, timeline);
timeline.signal.completed.connect(board_transition_complete);
@@ -98,8 +97,11 @@ GameView = new GType({
timeline = new Clutter.Timeline({duration: 500});
+ create_next_board();
+
new_board_view.depth = context.direction * -250;
new_board_view.opacity = 0;
+
new_board_view.show();
new_board_view.swap_in(context.direction, timeline);
@@ -113,6 +115,7 @@ GameView = new GType({
var theme_changed = function()
{
+ // TODO: only animate if theme changes!
timeline = new Clutter.Timeline({duration: 1500});
create_next_board();
@@ -169,3 +172,4 @@ GameView = new GType({
Settings.Watcher.signal.theme_changed.connect(theme_changed);
}
});
+
diff --git a/lightsoff/Light.js.in b/lightsoff/Light.js.in
index 3d8267a..5ae064e 100644
--- a/lightsoff/Light.js.in
+++ b/lightsoff/Light.js.in
@@ -24,23 +24,33 @@ LightView = new GType({
{
state = new_state;
- // Animate the opacity of the 'off' tile to match the state.
- off.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
+ if(timeline)
{
- opacity: (state ? 0 : 255)
- });
+ // Animate the opacity of the 'off' tile to match the state.
+ off.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
+ {
+ opacity: (state ? 0 : 255)
+ });
- on.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
- {
- opacity: (state ? 255 : 0)
- });
+ on.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
+ {
+ opacity: (state ? 255 : 0)
+ });
- // Animate the tile to be smaller when in the 'off' state.
- self.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
+ // Animate the tile to be smaller when in the 'off' state.
+ self.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_SINE, timeline,
+ {
+ scale_x: (state ? 1 : 0.9),
+ scale_y: (state ? 1 : 0.9)
+ });
+ }
+ else
{
- scale_x: (state ? 1 : 0.9),
- scale_y: (state ? 1 : 0.9)
- });
+ off.opacity = (state ? 0 : 255);
+ on.opacity = (state ? 255 : 0);
+ self.scale_x = (state ? 1 : 0.9);
+ self.scale_y = (state ? 1 : 0.9);
+ }
}
this.get_state = function()
@@ -58,6 +68,8 @@ LightView = new GType({
this.add_actor(on);
this.add_actor(off);
+ off.raise_top();
+
this.set_scale(0.9, 0.9);
this.reactive = true;
this.anchor_gravity = Clutter.Gravity.CENTER;
diff --git a/lightsoff/main.js.in b/lightsoff/main.js.in
index 1e5734c..cd07e3f 100755
--- a/lightsoff/main.js.in
+++ b/lightsoff/main.js.in
@@ -32,6 +32,8 @@ b.get_object("vbox1").pack_start(clutter_embed, true, true);
var stage = clutter_embed.get_stage();
stage.color = {alpha:255};
+Settings.theme.map_stuff(stage);
+
var game = new Game.GameView();
stage.add_actor(game);
stage.set_size(game.width, game.height);
diff --git a/lightsoff/themes/tango/theme.js.in b/lightsoff/themes/tango/theme.js.in
index 2dd139b..5e7a906 100644
--- a/lightsoff/themes/tango/theme.js.in
+++ b/lightsoff/themes/tango/theme.js.in
@@ -10,6 +10,26 @@ var backing = load_svg("backing.svg");
var led_back = load_svg("led-back.svg");
var led_front = load_svg("led-front.svg");
+// TODO: figure out how to fix this new offscreen cloning thing. this is a hack.
+
+function map_stuff(a)
+{
+ a.add_actor(light[0]);
+ a.add_actor(light[1]);
+ a.add_actor(arrow);
+ a.add_actor(backing);
+ a.add_actor(led_back);
+ a.add_actor(led_front);
+ a.show_all();
+
+ light[0].set_position(-500, -500);
+ light[1].set_position(-500, -500);
+ arrow.set_position(-500, -500);
+ backing.set_position(-500, -500);
+ led_back.set_position(-500, -500);
+ led_front.set_position(-500, -500);
+}
+
// helper functions should be put somewhere global
function load_svg(file)
diff --git a/lightsoff/themes/up/theme.js.in b/lightsoff/themes/up/theme.js.in
index d895bd3..8d49a5c 100644
--- a/lightsoff/themes/up/theme.js.in
+++ b/lightsoff/themes/up/theme.js.in
@@ -10,6 +10,26 @@ var backing = load_svg("backing.svg");
var led_back = load_svg("led-back.svg");
var led_front = load_svg("led-front.svg");
+// TODO: figure out how to fix this new offscreen cloning thing. this is a hack.
+
+function map_stuff(a)
+{
+ a.add_actor(light[0]);
+ a.add_actor(light[1]);
+ a.add_actor(arrow);
+ a.add_actor(backing);
+ a.add_actor(led_back);
+ a.add_actor(led_front);
+ a.show_all();
+
+ light[0].set_position(-500, -500);
+ light[1].set_position(-500, -500);
+ arrow.set_position(-500, -500);
+ backing.set_position(-500, -500);
+ led_back.set_position(-500, -500);
+ led_front.set_position(-500, -500);
+}
+
// helper functions should be put somewhere global
function load_svg(file)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]