entityjs 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/bin/entityjs +1 -1
- data/entityjs.gemspec +3 -2
- data/lib/entityjs.rb +13 -1
- data/lib/entityjs/command.rb +22 -16
- data/lib/entityjs/commands/build.rb +96 -48
- data/lib/entityjs/commands/eunit.rb +1 -1
- data/lib/entityjs/commands/html.rb +31 -0
- data/lib/entityjs/commands/min.rb +37 -0
- data/lib/entityjs/commands/new.rb +3 -0
- data/lib/entityjs/commands/server.rb +9 -3
- data/lib/entityjs/config.rb +163 -59
- data/lib/entityjs/dirc.rb +28 -0
- data/lib/entityjs/page.rb +73 -34
- data/lib/entityjs/version.rb +1 -1
- data/public/favicon.ico +0 -0
- data/public/play.html +33 -28
- data/public/qunit/qunit.entity.js +56 -6
- data/public/qunit/qunit.input.js +5 -5
- data/public/test.html +49 -0
- data/spec/javascripts/src/core/comp_spec.js +17 -6
- data/spec/javascripts/src/core/entity_spec.js +4 -5
- data/spec/javascripts/src/core/query_spec.js +25 -0
- data/spec/javascripts/src/core/re_spec.js +3 -3
- data/spec/javascripts/src/cycle/update_spec.js +8 -8
- data/spec/javascripts/src/display/align_spec.js +2 -2
- data/spec/javascripts/src/display/el_spec.js +17 -0
- data/spec/javascripts/src/input/keyboard_spec.js +4 -4
- data/spec/javascripts/src/input/mouse_spec.js +8 -7
- data/spec/javascripts/src/math/random_spec.js +8 -0
- data/spec/javascripts/src/util/clone_spec.js +20 -0
- data/spec/lib/entityjs/commands/build_spec.rb +3 -8
- data/spec/lib/entityjs/commands/html_spec.rb +27 -0
- data/spec/lib/entityjs/commands/min_spec.rb +30 -0
- data/spec/lib/entityjs/config_spec.rb +6 -0
- data/spec/lib/entityjs/page_spec.rb +4 -4
- data/src/core/comp.js +87 -31
- data/src/core/entity.js +38 -43
- data/src/core/load.js +2 -8
- data/src/core/query.js +17 -5
- data/src/core/re.js +1 -1
- data/src/core/system.js +8 -11
- data/src/cycle/drawlist.js +11 -11
- data/src/cycle/update.js +5 -5
- data/src/display/align.js +10 -3
- data/src/display/animate.js +26 -12
- data/src/display/el.js +99 -0
- data/src/input/keyboard.js +5 -5
- data/src/input/mouse.js +16 -11
- data/src/math/bisect.js +1 -1
- data/src/math/force.js +4 -4
- data/src/math/hitmap.js +2 -1
- data/src/math/iso.js +1 -1
- data/src/math/random.js +17 -2
- data/src/math/tile.js +1 -1
- data/src/media/sound.js +1 -1
- data/src/pattern/pathfind.js +2 -4
- data/src/save/storage.js +1 -1
- data/src/util/clone.js +12 -0
- data/src/util/scene.js +21 -16
- data/templates/circle/game.json +16 -0
- data/templates/circle/scripts/displays/circle.js +40 -0
- data/templates/circle/scripts/scenes/home.js +8 -17
- data/templates/circle/tests/scenes/home_test.js +3 -11
- data/templates/dom/game.json +6 -0
- data/templates/dom/scripts/els/btn.js +5 -0
- data/templates/dom/scripts/els/contain.js +5 -0
- data/templates/dom/scripts/els/header.js +5 -0
- data/templates/{animation → dom}/scripts/init.js +0 -0
- data/templates/dom/scripts/scenes/home.js +22 -0
- data/templates/{animation → dom}/scripts/scenes/load.js +0 -0
- data/templates/dom/tests/scenes/home_test.js +9 -0
- data/templates/{animation → dom}/tests/scenes/load_test.js +0 -0
- data/templates/isometric/game.json +16 -0
- data/templates/platform/game.json +18 -0
- data/templates/platform/scripts/displays/hero.js +1 -1
- data/templates/platform/scripts/items/coin.js +1 -1
- data/templates/platform/scripts/items/spring.js +1 -1
- data/templates/platform/tests/displays/hero_test.js +4 -4
- data/templates/platform/tests/factories.js +1 -1
- data/templates/platform/tests/items/coin_test.js +1 -1
- data/templates/pong/game.json +16 -0
- data/templates/tiltmaze/game.json +16 -0
- data/templates/tiltmaze/scripts/structs/level.js +1 -1
- data/templates/tiltmaze/scripts/tiles/walltile.js +1 -1
- metadata +45 -32
- data/.rspec +0 -2
- data/public/tests.html +0 -31
- data/src/cycle/worker.js +0 -9
- data/templates/animation/assets/images/hero.png +0 -0
- data/templates/animation/scripts/scenes/home.js +0 -41
- data/templates/animation/tests/init_test.js +0 -4
- data/templates/animation/tests/scenes/home_test.js +0 -15
- data/templates/arrow_keys/assets/images/arrow.png +0 -0
- data/templates/arrow_keys/config.yml +0 -22
- data/templates/arrow_keys/readme.txt +0 -9
- data/templates/arrow_keys/scripts/displays/arrow.js +0 -69
- data/templates/arrow_keys/scripts/init.js +0 -10
- data/templates/arrow_keys/scripts/inputs/controls.js +0 -35
- data/templates/arrow_keys/scripts/scenes/home.js +0 -20
- data/templates/arrow_keys/scripts/scenes/load.js +0 -57
- data/templates/arrow_keys/tests/displays/arrow_test.js +0 -29
- data/templates/arrow_keys/tests/init_test.js +0 -4
- data/templates/arrow_keys/tests/inputs/controls_test.js +0 -32
- data/templates/arrow_keys/tests/scenes/home_test.js +0 -0
- data/templates/arrow_keys/tests/scenes/load_test.js +0 -18
- data/templates/circle/config.yml +0 -22
- data/templates/isometric/config.yml +0 -22
- data/templates/platform/config.yml +0 -23
- data/templates/pong/config.yml +0 -22
- data/templates/tiltmaze/config.yml +0 -25
data/src/core/entity.js
CHANGED
|
@@ -11,9 +11,14 @@
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
*/
|
|
14
|
-
var q = function(c, count){
|
|
14
|
+
var q = function(c, count, alone){
|
|
15
15
|
if(!count){
|
|
16
|
-
|
|
16
|
+
var r = new re.entity.init(c);
|
|
17
|
+
|
|
18
|
+
if(!alone){
|
|
19
|
+
re._e.push(r);
|
|
20
|
+
}
|
|
21
|
+
return r;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
//optimize for multiple calls
|
|
@@ -21,42 +26,32 @@
|
|
|
21
26
|
|
|
22
27
|
//create entity by number of count
|
|
23
28
|
for(var i=0; i<count; i++){
|
|
24
|
-
q.push(re.e(c));
|
|
29
|
+
q.push(re.e(c, 0, alone));
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
return q;
|
|
28
33
|
};
|
|
29
34
|
|
|
30
|
-
q.id = 0;
|
|
31
|
-
|
|
32
35
|
var e = function(c){
|
|
33
36
|
|
|
34
37
|
this._re_comps = [];
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
this.id = q.id+'';
|
|
38
|
-
|
|
39
|
-
q.id++;
|
|
40
|
-
|
|
41
|
-
re._e.push(this);
|
|
38
|
+
this._re_listens = {};
|
|
42
39
|
|
|
43
40
|
this.comp(c);
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
var p = e.prototype;
|
|
47
44
|
|
|
48
|
-
p.id = '';
|
|
49
|
-
|
|
50
45
|
p.comp = function(com){
|
|
51
46
|
|
|
52
47
|
this._re_comp(com);
|
|
53
48
|
|
|
54
49
|
//check implement
|
|
55
|
-
if(this.
|
|
50
|
+
if(this._re_interfaces){
|
|
56
51
|
|
|
57
|
-
for(var i in this.
|
|
58
|
-
if(!this.hasOwnProperty(this.
|
|
59
|
-
throw 'Interface: '+this.
|
|
52
|
+
for(var i in this._re_interfaces){
|
|
53
|
+
if(!this.hasOwnProperty(this._re_interfaces[i])){
|
|
54
|
+
throw 'Interface: '+this._re_interfaces[i]+' missing';
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
57
|
|
|
@@ -155,16 +150,17 @@
|
|
|
155
150
|
//component reference
|
|
156
151
|
var c;
|
|
157
152
|
|
|
153
|
+
//will be sent to init function
|
|
158
154
|
var vals = com.split(':');
|
|
159
155
|
|
|
160
156
|
com = vals[0];
|
|
161
157
|
|
|
158
|
+
//remove comp string
|
|
159
|
+
vals.shift();
|
|
160
|
+
|
|
162
161
|
//add component
|
|
163
162
|
c = re._c[com];
|
|
164
|
-
|
|
165
|
-
//swap values
|
|
166
|
-
vals[0] = c;
|
|
167
|
-
|
|
163
|
+
|
|
168
164
|
//if already has component
|
|
169
165
|
if(!this.has(com)){
|
|
170
166
|
|
|
@@ -177,11 +173,11 @@
|
|
|
177
173
|
this._re_comp(c._re_requires);
|
|
178
174
|
|
|
179
175
|
//add interface of component
|
|
180
|
-
if(c.
|
|
181
|
-
if(!this.
|
|
182
|
-
this.
|
|
176
|
+
if(c._re_interfaces){
|
|
177
|
+
if(!this._re_interfaces){
|
|
178
|
+
this._re_interfaces = [];
|
|
183
179
|
}
|
|
184
|
-
this.
|
|
180
|
+
this._re_interfaces = this._re_interfaces.concat(c._re_interfaces);
|
|
185
181
|
}
|
|
186
182
|
|
|
187
183
|
if(c._re_asserts){
|
|
@@ -191,8 +187,8 @@
|
|
|
191
187
|
this._re_asserts = this._re_asserts.concat(c._re_asserts);
|
|
192
188
|
}
|
|
193
189
|
|
|
194
|
-
if(c.
|
|
195
|
-
this.def(c.
|
|
190
|
+
if(c._re_defaults){
|
|
191
|
+
this.def(c._re_defaults);
|
|
196
192
|
}
|
|
197
193
|
|
|
198
194
|
if(c._re_defines){
|
|
@@ -223,8 +219,8 @@
|
|
|
223
219
|
return this._re_comps.slice();
|
|
224
220
|
}
|
|
225
221
|
|
|
226
|
-
p.clone = function(count){
|
|
227
|
-
return re.e(this._re_comps, count);
|
|
222
|
+
p.clone = function(count, a){
|
|
223
|
+
return re.e(this._re_comps, count, a);
|
|
228
224
|
}
|
|
229
225
|
|
|
230
226
|
/*
|
|
@@ -251,7 +247,7 @@
|
|
|
251
247
|
return c._re_defines[method].apply(this, a);
|
|
252
248
|
}
|
|
253
249
|
|
|
254
|
-
return c.
|
|
250
|
+
return c._re_defaults[method].apply(this, a);
|
|
255
251
|
}
|
|
256
252
|
|
|
257
253
|
/*
|
|
@@ -306,7 +302,7 @@
|
|
|
306
302
|
//check if entity contains signals
|
|
307
303
|
for(p=0; p<comp.on.length; p++){
|
|
308
304
|
s = comp.on[p];
|
|
309
|
-
if(!this.
|
|
305
|
+
if(!this._re_listens[s] || this._re_listens[s].length == 0){
|
|
310
306
|
return false;
|
|
311
307
|
}
|
|
312
308
|
}
|
|
@@ -343,12 +339,12 @@
|
|
|
343
339
|
|
|
344
340
|
} else {
|
|
345
341
|
|
|
346
|
-
if(!this.
|
|
347
|
-
this.
|
|
342
|
+
if(!this._re_listens[type]){
|
|
343
|
+
this._re_listens[type] = [];
|
|
348
344
|
}
|
|
349
345
|
if(!re.is(method)) throw 'Method is null'
|
|
350
346
|
//save context
|
|
351
|
-
this.
|
|
347
|
+
this._re_listens[type].push({c:context || this, f:method});
|
|
352
348
|
|
|
353
349
|
}
|
|
354
350
|
|
|
@@ -385,7 +381,7 @@
|
|
|
385
381
|
} else {
|
|
386
382
|
|
|
387
383
|
if(method){
|
|
388
|
-
var i = this.
|
|
384
|
+
var i = this._re_listens[type];
|
|
389
385
|
for(var k in i){
|
|
390
386
|
|
|
391
387
|
if(i[k].f == method){
|
|
@@ -396,11 +392,11 @@
|
|
|
396
392
|
} else if(type){
|
|
397
393
|
|
|
398
394
|
//no method was passed. Remove all signals
|
|
399
|
-
this.
|
|
395
|
+
this._re_listens[type] = [];
|
|
400
396
|
|
|
401
397
|
} else {
|
|
402
398
|
//remove all signals
|
|
403
|
-
this.
|
|
399
|
+
this._re_listens = {};
|
|
404
400
|
}
|
|
405
401
|
}
|
|
406
402
|
|
|
@@ -417,12 +413,12 @@
|
|
|
417
413
|
*/
|
|
418
414
|
p.trigger = function(type){
|
|
419
415
|
|
|
420
|
-
if(!this.
|
|
416
|
+
if(!this._re_listens[type]) return this;
|
|
421
417
|
var b;
|
|
422
418
|
|
|
423
|
-
for(var i=0, l = this.
|
|
419
|
+
for(var i=0, l = this._re_listens[type].length; i<l; i++){
|
|
424
420
|
|
|
425
|
-
b = this.
|
|
421
|
+
b = this._re_listens[type];
|
|
426
422
|
|
|
427
423
|
if(!b) break;
|
|
428
424
|
if(!b[i]) continue;
|
|
@@ -465,8 +461,7 @@
|
|
|
465
461
|
};
|
|
466
462
|
|
|
467
463
|
p.get = function(v){
|
|
468
|
-
|
|
469
|
-
return (re.is(l,'function'))? l() : l;
|
|
464
|
+
return (re.is(this[v], 'function'))? this[v]() : this[v];
|
|
470
465
|
};
|
|
471
466
|
|
|
472
467
|
p.def = function(obj, value){
|
data/src/core/load.js
CHANGED
|
@@ -131,13 +131,10 @@
|
|
|
131
131
|
//create new image component
|
|
132
132
|
re.c(a)
|
|
133
133
|
.alias(n+re.load.imageExt)
|
|
134
|
-
.statics({
|
|
135
|
-
image:img
|
|
136
|
-
})
|
|
137
134
|
.defines({
|
|
138
135
|
//save image for other components to copy or use
|
|
139
136
|
_image:img
|
|
140
|
-
});
|
|
137
|
+
}).image = img;
|
|
141
138
|
|
|
142
139
|
img.onload = function(){
|
|
143
140
|
re.c(a).defines({
|
|
@@ -236,12 +233,9 @@
|
|
|
236
233
|
re.c(a)
|
|
237
234
|
//create statics codec for easy use
|
|
238
235
|
.alias(n+re.load.soundExt)
|
|
239
|
-
.statics({
|
|
240
|
-
sound:s
|
|
241
|
-
})
|
|
242
236
|
.defines({
|
|
243
237
|
_sound:s
|
|
244
|
-
});
|
|
238
|
+
}).sound = s;
|
|
245
239
|
}
|
|
246
240
|
|
|
247
241
|
p.progress = function(m){
|
data/src/core/query.js
CHANGED
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
Sort a query string into objects
|
|
64
64
|
*/
|
|
65
65
|
q._toObj = function(query){
|
|
66
|
+
//check if its caught
|
|
66
67
|
if(q.c[query]){
|
|
67
68
|
return q.c[query];
|
|
68
69
|
}
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
id:id
|
|
100
101
|
};
|
|
101
102
|
|
|
103
|
+
//catch it
|
|
102
104
|
q.c[query] = comp;
|
|
103
105
|
|
|
104
106
|
return comp;
|
|
@@ -168,7 +170,7 @@
|
|
|
168
170
|
while(++i < l && (e = this[i]) != null && m.call(context || this, e, i, this) !== false);
|
|
169
171
|
|
|
170
172
|
return this;
|
|
171
|
-
}
|
|
173
|
+
};
|
|
172
174
|
|
|
173
175
|
/*
|
|
174
176
|
The map method allows multidimensional loops.
|
|
@@ -371,23 +373,33 @@
|
|
|
371
373
|
return re(Array.prototype.filter.apply(this, arguments));
|
|
372
374
|
}
|
|
373
375
|
|
|
376
|
+
//Removes all elements in the array that pass the truth test
|
|
377
|
+
p.reject = function(it, c){
|
|
378
|
+
for(var i=0; i<this.length; i++){
|
|
379
|
+
if(it.call(c || this, this[i], i, this)){
|
|
380
|
+
this.splice(i, 1);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return this;
|
|
384
|
+
};
|
|
385
|
+
|
|
374
386
|
/*
|
|
375
387
|
Finds first entity with components
|
|
376
388
|
|
|
377
389
|
re('draw').findWith('circle !red');
|
|
378
390
|
|
|
379
391
|
*/
|
|
380
|
-
p.findWith = function(comps
|
|
392
|
+
p.findWith = function(comps){
|
|
381
393
|
return this.find(function(e){
|
|
382
394
|
return e.has(comps);
|
|
383
|
-
}
|
|
395
|
+
});
|
|
384
396
|
}
|
|
385
397
|
|
|
386
398
|
/*
|
|
387
399
|
Creates a new entity and pushes it into the array.
|
|
388
400
|
*/
|
|
389
|
-
p.e = function(comps, count){
|
|
390
|
-
var e = re.e(comps, count);
|
|
401
|
+
p.e = function(comps, count, alone){
|
|
402
|
+
var e = re.e(comps, count, alone);
|
|
391
403
|
if(count){
|
|
392
404
|
//add all in query
|
|
393
405
|
for(var i in e){
|
data/src/core/re.js
CHANGED
data/src/core/system.js
CHANGED
|
@@ -88,14 +88,14 @@ re.c('system')
|
|
|
88
88
|
this.sizeY = s.sizeY = this.canvas.height;
|
|
89
89
|
|
|
90
90
|
//init listeners
|
|
91
|
-
if(re.
|
|
92
|
-
re.
|
|
91
|
+
if(re.keyboard){
|
|
92
|
+
re.keyboard.i();
|
|
93
93
|
}
|
|
94
|
-
if(re.
|
|
95
|
-
re.
|
|
94
|
+
if(re.mouse){
|
|
95
|
+
re.mouse.i();
|
|
96
96
|
}
|
|
97
|
-
if(re.
|
|
98
|
-
re.
|
|
97
|
+
if(re.touch){
|
|
98
|
+
re.touch.i();
|
|
99
99
|
}
|
|
100
100
|
this.system_loop = this.defaultLoop;
|
|
101
101
|
this.second = this.stepSize * 30;
|
|
@@ -119,7 +119,7 @@ re.c('system')
|
|
|
119
119
|
},
|
|
120
120
|
|
|
121
121
|
update:function(){
|
|
122
|
-
re.
|
|
122
|
+
re.update.update(this.stepSize);
|
|
123
123
|
},
|
|
124
124
|
|
|
125
125
|
draw:function(){
|
|
@@ -129,9 +129,6 @@ re.c('system')
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
})
|
|
132
|
-
.run(function(){
|
|
133
132
|
|
|
134
133
|
//create default system
|
|
135
|
-
re.system = re.sys = re.e('system');
|
|
136
|
-
|
|
137
|
-
});
|
|
134
|
+
re.system = re.sys = re.e('system');
|
data/src/cycle/drawlist.js
CHANGED
|
@@ -10,20 +10,20 @@ For example:
|
|
|
10
10
|
In a case of an isometric game, certain tiles should appear behind or in
|
|
11
11
|
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
re.c('drawlist')
|
|
15
|
+
.method(function(name){
|
|
16
|
+
var name = name || '';
|
|
15
17
|
|
|
16
18
|
//name default to '' and returns default drawlist
|
|
17
19
|
|
|
18
|
-
if(!
|
|
20
|
+
if(!re.drawlist._lists[name]){
|
|
19
21
|
//add new list
|
|
20
22
|
re.e('drawlist:'+name);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
re.c('drawlist')
|
|
25
|
+
return re.drawlist._lists[name];
|
|
26
|
+
})
|
|
27
27
|
.statics({
|
|
28
28
|
_lists:{}
|
|
29
29
|
})
|
|
@@ -69,11 +69,11 @@ re.c('drawlist')
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
})
|
|
72
|
-
.init(function(
|
|
73
|
-
|
|
72
|
+
.init(function(name){
|
|
73
|
+
re.drawlist._lists[name] = this;
|
|
74
74
|
this.listName = name;
|
|
75
75
|
this.list = re();
|
|
76
76
|
})
|
|
77
|
-
.dispose(function(
|
|
78
|
-
delete
|
|
77
|
+
.dispose(function(){
|
|
78
|
+
delete re.drawlist._lists[this.listName];
|
|
79
79
|
});
|
data/src/cycle/update.js
CHANGED
|
@@ -23,7 +23,7 @@ re.c('update')
|
|
|
23
23
|
})
|
|
24
24
|
.defines(function(){
|
|
25
25
|
|
|
26
|
-
var l = re.
|
|
26
|
+
var l = re.update.l;
|
|
27
27
|
|
|
28
28
|
return {
|
|
29
29
|
|
|
@@ -78,10 +78,10 @@ re.c('update')
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
}())
|
|
81
|
-
.init(function(
|
|
82
|
-
|
|
81
|
+
.init(function(){
|
|
82
|
+
re.update.l.push(this);
|
|
83
83
|
})
|
|
84
|
-
.dispose(function(
|
|
84
|
+
.dispose(function(){
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
re.update.l.splice(re.update.l.indexOf(this), 1);
|
|
87
87
|
});
|
data/src/display/align.js
CHANGED
|
@@ -5,13 +5,20 @@ The align component contains helper methods for positioning entities relative to
|
|
|
5
5
|
|
|
6
6
|
*/
|
|
7
7
|
re.c('align')
|
|
8
|
-
.
|
|
8
|
+
.defaults({
|
|
9
|
+
regX:0,
|
|
10
|
+
regY:0,
|
|
11
|
+
sizeX:1,
|
|
12
|
+
sizeY:1,
|
|
13
|
+
posX:0,
|
|
14
|
+
posY:0
|
|
15
|
+
})
|
|
9
16
|
.defines({
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
align:function(x, y){
|
|
12
19
|
this.alignHor(x);
|
|
13
20
|
return this.alignVer(y);
|
|
14
|
-
|
|
21
|
+
},
|
|
15
22
|
|
|
16
23
|
alignHor:function(o){
|
|
17
24
|
o = o || 0;
|
data/src/display/animate.js
CHANGED
|
@@ -5,7 +5,7 @@ The animate comp defines a simple interface for animating sprites.
|
|
|
5
5
|
var apple = re.e('apple.png animate sprite');
|
|
6
6
|
|
|
7
7
|
//setup animations to play
|
|
8
|
-
apple.
|
|
8
|
+
apple.animates = {
|
|
9
9
|
//time, frames, loops
|
|
10
10
|
explode:[1000, [0, 1, 2], 1]
|
|
11
11
|
//seconds, frames, loops defaults to once
|
|
@@ -25,26 +25,40 @@ apple.flickering(); //this comes from flicker comp
|
|
|
25
25
|
re.c('animate')
|
|
26
26
|
.requires('flicker')
|
|
27
27
|
.defines({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
//overload flickers method
|
|
30
|
+
flicker_stop:function(){
|
|
31
|
+
this._super('flicker', 'flicker_stop');
|
|
32
|
+
if(this.animate_finish) this.animate_finish();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
animate:function(name, onFinish, onUpdate){
|
|
36
|
+
//ignore if calling the same animation
|
|
31
37
|
if(this.flickering() != name){
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
|
|
39
|
+
this.animate_finish = onFinish;
|
|
40
|
+
this.animate_update = onUpdate;
|
|
41
|
+
|
|
42
|
+
var a = this.animates[name];
|
|
34
43
|
//flicker interface
|
|
35
44
|
//(duration:int, frames:array, loops:int, id:string)
|
|
36
45
|
this.flicker(a[0], a[1], a[2], name);
|
|
37
46
|
|
|
38
47
|
//only run if a is defined
|
|
39
|
-
if(a.
|
|
40
|
-
|
|
48
|
+
if(a.push)
|
|
49
|
+
this.flicker_run(); //run first frame
|
|
41
50
|
}
|
|
42
51
|
return this;
|
|
43
52
|
},
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
animating:function(t){
|
|
55
|
+
return this.flickering(t);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
//implement for flicker
|
|
59
|
+
flick:function(c){
|
|
60
|
+
this.frame(c);
|
|
61
|
+
if(this.animate_update) this.animate_update.apply(this, arguments);
|
|
62
|
+
}
|
|
49
63
|
|
|
50
64
|
});
|