~ubuntu-branches/ubuntu/precise/gnome-games/precise-updates

« back to all changes in this revision

Viewing changes to swell-foop/src/Light.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-19 20:46:10 UTC
  • mfrom: (1.1.105)
  • Revision ID: package-import@ubuntu.com-20120319204610-2nd2xqq39j8y7t5q
Tags: 1:3.3.92-0ubuntu1
* New upstream release.
  - Swell Foop ported to Vala, no longer in staging
    (LP: #939200, LP: #939210)
* debian/patches/git_fix-iagno-ai.patch: Dropped, upstream
* debian/control.in:
  - Drop no longer needed swell-foop dependencies
* debian/rules:
  - Don't install staging games
* debian/swell-foop.install:
  - Don't install gir files any more; they're not needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Clutter = imports.gi.Clutter;
2
 
GLib = imports.gi.GLib;
3
 
main = imports.main;
4
 
Settings = imports.Settings;
5
 
 
6
 
Light = new GType({
7
 
        parent: Clutter.Group.type,
8
 
        name: "Light",
9
 
        init: function(self)
10
 
        {
11
 
                // Private
12
 
                var closed = false;
13
 
                var light_x, light_y;
14
 
                var state = Math.floor(Math.random() * Settings.colors);
15
 
        
16
 
                function theme_changed()
17
 
                {
18
 
                        self.remove_actor(self.on);
19
 
                        self.on = new Clutter.Clone({source: Settings.theme.colors[state]});
20
 
                        self.on.set_size(main.tile_size, main.tile_size);       
21
 
                        self.add_actor(self.on);
22
 
                }
23
 
                
24
 
                // Public
25
 
                this.visited = false;
26
 
        
27
 
                this.on = new Clutter.Clone({source: Settings.theme.colors[state]});
28
 
        
29
 
                this.get_state = function ()
30
 
                {
31
 
                        return state;
32
 
                };
33
 
        
34
 
                this.animate_out = function (timeline)
35
 
                {
36
 
                        this.on.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
37
 
                        {
38
 
                                height: main.tile_size * 2,
39
 
                                width: main.tile_size * 2,
40
 
                                x: -main.tile_size/2,
41
 
                                y: -main.tile_size/2
42
 
                        });
43
 
                        
44
 
                        this.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
45
 
                        {
46
 
                           opacity: 0
47
 
                        });
48
 
                        
49
 
                        timeline.signal.completed.connect(this.hide_light, this);
50
 
                        
51
 
                        // GLib.main_context_iteration();
52
 
                };
53
 
        
54
 
                this.animate_to = function (new_x, new_y, timeline)
55
 
                {
56
 
                        var anim_mode = Settings.zealous ?
57
 
                                                Clutter.AnimationMode.EASE_OUT_BOUNCE :
58
 
                                                Clutter.AnimationMode.EASE_OUT_QUAD;
59
 
                        this.animate_with_timeline(anim_mode, timeline,
60
 
                        {
61
 
                                x: new_x,
62
 
                                y: new_y
63
 
                        });
64
 
                        
65
 
                        // GLib.main_context_iteration();
66
 
                };
67
 
        
68
 
                this.get_closed = function ()
69
 
                {
70
 
                        return closed;
71
 
                };
72
 
        
73
 
                this.close_tile = function (timeline)
74
 
                {
75
 
                        closed = true;
76
 
                        this.animate_out(timeline);
77
 
                };
78
 
        
79
 
                this.hide_light = function (timeline, light)
80
 
                {
81
 
                        light.hide();
82
 
                        
83
 
                        delete on;
84
 
                        
85
 
                        if(light.anim)
86
 
                        delete light.anim;
87
 
                        
88
 
                        return false;
89
 
                };
90
 
        
91
 
                this.set_light_x = function (new_x)
92
 
                {
93
 
                        light_x = new_x;
94
 
                };
95
 
        
96
 
                this.set_light_y = function (new_y)
97
 
                {
98
 
                        light_y = new_y;
99
 
                };
100
 
        
101
 
                this.get_light_x = function ()
102
 
                {
103
 
                        return light_x;
104
 
                };
105
 
        
106
 
                this.get_light_y = function ()
107
 
                {
108
 
                        return light_y;
109
 
                };
110
 
        
111
 
                // Implementation
112
 
                this.on.set_size(main.tile_size, main.tile_size);
113
 
        
114
 
                this.opacity = 180;
115
 
                this.reactive = true;
116
 
        
117
 
                this.set_anchor_point(main.tile_size / 2, main.tile_size / 2);
118
 
        
119
 
                this.add_actor(new Clutter.Rectangle({width: main.tile_size, height: main.tile_size, color: {alpha:255}}));
120
 
                this.add_actor(this.on);
121
 
        
122
 
                Settings.Watcher.signal.theme_changed.connect(theme_changed);
123
 
        }
124
 
});
125
 
 
126