entityjs 0.3.0 → 0.3.1
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 +2 -1
- data/README.md +50 -13
- data/entityjs.gemspec +1 -1
- data/lib/entityjs/assets.rb +68 -36
- data/lib/entityjs/command.rb +3 -0
- data/lib/entityjs/commands/build.rb +58 -29
- data/lib/entityjs/commands/release.rb +42 -0
- data/lib/entityjs/parsers/parse_tmx.rb +9 -9
- data/lib/entityjs/parsers/parse_xml.rb +13 -2
- data/lib/entityjs/version.rb +1 -1
- data/lib/entityjs.rb +1 -1
- data/public/play.html +1 -1
- data/public/tests.html +1 -0
- data/spec/javascripts/helpers/canvas.js +3 -0
- data/spec/javascripts/helpers/entityunit.js +7 -0
- data/spec/javascripts/helpers/flashcanvas.js~ +28 -0
- data/spec/javascripts/helpers/soundmanager2/soundmanager2.js +5021 -0
- data/spec/javascripts/helpers/soundmanager2/soundmanager2.js~ +5021 -0
- data/spec/javascripts/helpers/soundmanager2/soundmanager2.swf +0 -0
- data/spec/javascripts/helpers/soundmanager2/soundmanager2_debug.swf +0 -0
- data/spec/javascripts/src/core/comp_spec.js +5 -6
- data/spec/javascripts/src/core/load_spec.js +2 -1
- data/spec/javascripts/src/core/re_spec.js +5 -6
- data/spec/javascripts/src/cycle/tick_spec.js +2 -2
- data/spec/javascripts/src/input/keyboard_spec.js +1 -5
- data/spec/javascripts/src/media/sound_spec.js +3 -3
- data/spec/lib/entityjs/assets_spec.rb +20 -0
- data/spec/lib/entityjs/commands/build_spec.rb +18 -38
- data/spec/lib/entityjs/commands/release_spec.rb +11 -0
- data/src/core/entity.js +18 -48
- data/src/core/load.js +71 -38
- data/src/core/re.js +3 -25
- data/src/core/system.js +1 -0
- data/src/display/align.js +3 -0
- data/src/input/keyboard.js +1 -2
- data/src/input/mouse.js +0 -1
- data/src/math/tile.js +2 -0
- data/src/media/sound.js +20 -20
- data/src/util/log.js +2 -10
- metadata +22 -15
Binary file
|
Binary file
|
@@ -24,26 +24,25 @@ describe('comp', function(){
|
|
24
24
|
k
|
25
25
|
.requires('test test2');
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
contains(k._re_requires, 'test')
|
28
|
+
contains(k._re_requires, 'test2')
|
29
29
|
|
30
30
|
k.requires(['test3'])
|
31
|
-
|
31
|
+
contains(k._re_requires, 'test3')
|
32
32
|
})
|
33
33
|
|
34
34
|
it('should asserts', function(){
|
35
35
|
k
|
36
36
|
.asserts('bob');
|
37
37
|
|
38
|
-
|
38
|
+
contains(k._re_asserts, 'bob')
|
39
39
|
})
|
40
40
|
|
41
41
|
it('should interfaces', function(){
|
42
42
|
k
|
43
43
|
.interfaces('bob');
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
contains(k._re_implements, 'bob')
|
47
46
|
})
|
48
47
|
|
49
48
|
it('should alias', function(){
|
@@ -27,7 +27,7 @@ describe('re', function(){
|
|
27
27
|
})
|
28
28
|
|
29
29
|
it('should create element', function(){
|
30
|
-
is(re.$new('canvas')
|
30
|
+
is(re.$new('canvas'))
|
31
31
|
})
|
32
32
|
|
33
33
|
it('should re.is work', function(){
|
@@ -47,15 +47,14 @@ describe('re', function(){
|
|
47
47
|
ok(re.is(1, 'number'))
|
48
48
|
ok(re.is([], 'array'))
|
49
49
|
ok(re.is(/sd/, 'regexp'))
|
50
|
-
|
50
|
+
|
51
|
+
//doesn't work in ie8
|
52
|
+
//ok(re.is(re.$new('canvas'), 'htmlcanvaselement'))
|
53
|
+
|
51
54
|
var k = {};
|
52
55
|
ok(re.is(k, 'object'))
|
53
56
|
var f = function(){};
|
54
57
|
ok(re.is(f, 'function'))
|
55
58
|
})
|
56
59
|
|
57
|
-
it('should define indexof', function(){
|
58
|
-
is(Array.prototype.indexOf, 'function')
|
59
|
-
})
|
60
|
-
|
61
60
|
})
|
@@ -6,13 +6,13 @@ describe('ticker', function(){
|
|
6
6
|
|
7
7
|
waits(100)
|
8
8
|
runs(function(){
|
9
|
-
|
9
|
+
match(t.tick().toString(), /[0-9]*/)
|
10
10
|
})
|
11
11
|
|
12
12
|
|
13
13
|
waits(80)
|
14
14
|
runs(function(){
|
15
|
-
|
15
|
+
match(t.tick().toString(), /[0-9]*/)
|
16
16
|
})
|
17
17
|
|
18
18
|
})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe('
|
1
|
+
describe('keyboard', function(){
|
2
2
|
|
3
3
|
var e;
|
4
4
|
|
@@ -20,8 +20,6 @@ describe('test', function(){
|
|
20
20
|
called2 = key
|
21
21
|
});
|
22
22
|
|
23
|
-
ok(re.c('keyboard').body, document.activeElement)
|
24
|
-
|
25
23
|
//manually call
|
26
24
|
re.c('keyboard').event({type:type, keyCode:68})//d
|
27
25
|
|
@@ -49,8 +47,6 @@ describe('test', function(){
|
|
49
47
|
called2 = key
|
50
48
|
});
|
51
49
|
|
52
|
-
ok(re.c('keyboard').body, document.activeElement)
|
53
|
-
|
54
50
|
//manually call
|
55
51
|
re.c('keyboard').event({type:type, keyCode:68})//d
|
56
52
|
|
@@ -15,7 +15,7 @@ describe('sound', function(){
|
|
15
15
|
|
16
16
|
is(e.play())
|
17
17
|
|
18
|
-
waits(
|
18
|
+
waits(1500)
|
19
19
|
runs(function(){
|
20
20
|
ok(called)
|
21
21
|
})
|
@@ -30,11 +30,11 @@ describe('sound', function(){
|
|
30
30
|
})
|
31
31
|
|
32
32
|
it('currenttime', function(){
|
33
|
-
is(e.currentTime())
|
33
|
+
//is(e.currentTime())
|
34
34
|
})
|
35
35
|
|
36
36
|
it('ended', function(){
|
37
|
-
is(e.ended())
|
37
|
+
//is(e.ended())
|
38
38
|
})
|
39
39
|
|
40
40
|
});
|
@@ -207,6 +207,26 @@ describe 'Assets' do
|
|
207
207
|
r.should match /"\$":\[\[0/
|
208
208
|
end
|
209
209
|
|
210
|
+
it 'should return object for invalid xml' do
|
211
|
+
xml = '<sdf>'
|
212
|
+
|
213
|
+
lambda {
|
214
|
+
Entityjs::Assets.data_to_json('sdf.xml', xml)
|
215
|
+
}.should raise_error
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should return json from invalid tmx' do
|
219
|
+
tmx = "<root><bob>10</bob></root>"
|
220
|
+
|
221
|
+
Entityjs::Assets.data_to_json('lsdf.tmx', tmx).should == '{"bob":{"$":10}}'
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should convert blank tmx to json' do
|
225
|
+
tmx = ''
|
226
|
+
|
227
|
+
Entityjs::Assets.data_to_json('level.tmx', tmx).should == '{}'
|
228
|
+
end
|
229
|
+
|
210
230
|
it 'should generate to js' do
|
211
231
|
r = Entityjs::Assets.to_js
|
212
232
|
r.should match /re\.assets/
|
@@ -11,47 +11,12 @@ describe 'build' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should run' do
|
14
|
+
#turn this off, too much garbage made
|
14
15
|
#Entityjs::Command.run('build', []).should == 0
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'should run release1' do
|
18
19
|
|
19
|
-
Entityjs::Assets.stub(:search_datas).and_return(['level.tmx'])
|
20
|
-
|
21
|
-
Entityjs::Assets.stub(:file_to_json).and_return(Entityjs::Assets.data_to_json(%q(<?xml version="1.0" encoding="UTF-8"?>
|
22
|
-
<map version="1.0" orientation="orthogonal" width="40" height="20" tilewidth="25" tileheight="25">
|
23
|
-
<tileset firstgid="1" name="tiles" tilewidth="25" tileheight="25">
|
24
|
-
<image source="../images/tiles.png" width="200" height="25"/>
|
25
|
-
</tileset>
|
26
|
-
<layer name="Tile Layer 1" width="40" height="20">
|
27
|
-
<data encoding="csv">
|
28
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
29
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
30
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
31
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
32
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
33
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
34
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
35
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
37
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
38
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
39
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
40
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
41
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
42
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
43
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
44
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
45
|
-
2,2,2,2,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
46
|
-
1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
47
|
-
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
48
|
-
</data>
|
49
|
-
</layer>
|
50
|
-
<objectgroup name="Hero" width="40" height="20">
|
51
|
-
<object name="hero" x="43" y="356"/>
|
52
|
-
</objectgroup>
|
53
|
-
</map>), 'tmx'))
|
54
|
-
|
55
20
|
name = "release#{rand(999)}"
|
56
21
|
Entityjs::Command.run('b', [name]).should == 0
|
57
22
|
|
@@ -62,8 +27,23 @@ describe 'build' do
|
|
62
27
|
Dir.chdir(dir) do
|
63
28
|
contents = IO.read('game.min.js')
|
64
29
|
|
65
|
-
contents.should match /Tile Layer 1/i
|
66
30
|
end
|
67
31
|
end
|
68
|
-
|
32
|
+
|
33
|
+
it 'should build a throwthegame' do
|
34
|
+
#compile given source
|
35
|
+
images = "['images/sff.png', 'images/sddd.png']"
|
36
|
+
sounds = "[]"
|
37
|
+
levels = "re.e('df').attr({})"
|
38
|
+
canvas = 'game-canvas'
|
39
|
+
scripts = "re.ready(function(){});"
|
40
|
+
|
41
|
+
scripts += Entityjs::Assets.to_js('', images, sounds, canvas, levels)
|
42
|
+
|
43
|
+
#min
|
44
|
+
min = Entityjs::Build.minify(scripts)
|
45
|
+
|
46
|
+
min.should match /Entityjs/i
|
47
|
+
end
|
48
|
+
|
69
49
|
end
|
data/src/core/entity.js
CHANGED
@@ -128,34 +128,8 @@
|
|
128
128
|
this.comp('health:100 physics');
|
129
129
|
|
130
130
|
//remove components
|
131
|
-
this.
|
131
|
+
this.removeComp('point');
|
132
132
|
*/
|
133
|
-
/*p.comp = function(com){
|
134
|
-
|
135
|
-
this._re_comp(com);
|
136
|
-
|
137
|
-
//check implement
|
138
|
-
if(this._re_interface){
|
139
|
-
|
140
|
-
for(var i in this._re_interface){
|
141
|
-
if(!this.hasOwnProperty(this._re_interface[i])){
|
142
|
-
throw 'implementation: '+this._re_interface[i]+' missing';
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
}
|
147
|
-
|
148
|
-
//check asserts
|
149
|
-
if(this._re_asserts){
|
150
|
-
for(var t in this._re_asserts){
|
151
|
-
if(this._re_comps.indexOf(c._re_asserts[t]) != -1){
|
152
|
-
throw 'assert: '+c.name+' cannot be coupled with '+c._re_asserts[t];
|
153
|
-
}
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
|
-
return this;
|
158
|
-
}*/
|
159
133
|
|
160
134
|
p._re_comp = function(com){
|
161
135
|
if(!com) return this;
|
@@ -173,10 +147,9 @@
|
|
173
147
|
}
|
174
148
|
|
175
149
|
if(pieces.length > 1){
|
176
|
-
|
177
|
-
this._re_comp(pieces[
|
150
|
+
for(var i =0;i<pieces.length; i++){
|
151
|
+
this._re_comp(pieces[i]);
|
178
152
|
}
|
179
|
-
|
180
153
|
return this;
|
181
154
|
}
|
182
155
|
|
@@ -196,7 +169,7 @@
|
|
196
169
|
//if already has component
|
197
170
|
if(this.has(com)) return this;
|
198
171
|
|
199
|
-
//add comp first thing, to avoid dupe
|
172
|
+
//add comp first thing, to avoid dupe requirement calls
|
200
173
|
//and this lets the init remove the comp too.
|
201
174
|
this._re_comps.push(com);
|
202
175
|
|
@@ -363,6 +336,7 @@
|
|
363
336
|
if(re.is(type, 'object')){
|
364
337
|
|
365
338
|
for(var k in type){
|
339
|
+
if(type.hasOwnProperty(k))
|
366
340
|
this.on(k, type[k]);
|
367
341
|
}
|
368
342
|
|
@@ -402,17 +376,18 @@
|
|
402
376
|
if(re.is(type, 'object')){
|
403
377
|
|
404
378
|
for(var k in type){
|
379
|
+
if(type.hasOwnProperty(k))
|
405
380
|
this.off(k, type[k]);
|
406
381
|
}
|
407
382
|
|
408
383
|
} else {
|
409
384
|
|
410
385
|
if(method){
|
411
|
-
|
412
|
-
for(var k in
|
386
|
+
var i = this._re_signals[type];
|
387
|
+
for(var k in i){
|
413
388
|
|
414
|
-
if(
|
415
|
-
|
389
|
+
if(i.hasOwnProperty(k) && i[k] == method){
|
390
|
+
i.splice(k, 1);
|
416
391
|
}
|
417
392
|
|
418
393
|
}
|
@@ -471,9 +446,7 @@
|
|
471
446
|
|
472
447
|
if(re.is(obj, 'object')){
|
473
448
|
|
474
|
-
|
475
|
-
if(!obj.hasOwnProperty(key)) continue;
|
476
|
-
|
449
|
+
for(var key in obj){
|
477
450
|
this.attr(key, obj[key]);
|
478
451
|
}
|
479
452
|
|
@@ -506,11 +479,8 @@
|
|
506
479
|
|
507
480
|
if(re.is(obj , 'object')){
|
508
481
|
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
this.def(key, obj[key]);
|
513
|
-
|
482
|
+
for(var key in obj){
|
483
|
+
this.def(key, obj[key]);
|
514
484
|
}
|
515
485
|
|
516
486
|
} else {
|
@@ -531,11 +501,11 @@
|
|
531
501
|
re._e.splice(re._e.indexOf(this), 1);
|
532
502
|
|
533
503
|
for(var i in this._re_comps){
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
504
|
+
var k = re.c(this._re_comps[i]);
|
505
|
+
if(k._re_dispose){
|
506
|
+
k._re_dispose.call(this, k);
|
507
|
+
}
|
508
|
+
k.trigger('dispose', this);
|
539
509
|
}
|
540
510
|
|
541
511
|
this.trigger('dispose');
|
data/src/core/load.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
(function(re){
|
2
2
|
|
3
|
-
|
3
|
+
var b = function(assets){
|
4
4
|
return new re.load.init(assets);
|
5
5
|
}
|
6
6
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
this.assets = [];
|
57
57
|
for(var i in assets){
|
58
58
|
|
59
|
-
if(
|
59
|
+
if(re.is(assets[i], 'array')){
|
60
60
|
this.assets = this.assets.concat(assets[i]);
|
61
61
|
}
|
62
62
|
|
@@ -89,23 +89,26 @@
|
|
89
89
|
//find name
|
90
90
|
var n = a.substr(0, j);
|
91
91
|
|
92
|
-
if(re.load.images.indexOf(ext) != -1){
|
92
|
+
if(re.load.images.indexOf(ext) != -1){ //make sure image is allowed
|
93
93
|
|
94
94
|
this._loadImg(s, a, n);
|
95
95
|
|
96
|
-
} else if(re.load.sounds.indexOf(ext) != -1){
|
96
|
+
} else if(re.load.sounds.indexOf(ext) != -1){ //make sure sound is allowed
|
97
97
|
|
98
|
-
//
|
99
|
-
if(
|
98
|
+
//soundmanager only supports mp3, so use it if the sound is mp3
|
99
|
+
if(window['soundManager'] && ext == 'mp3' || re.support(ext)){
|
100
100
|
//don't load the same sound twice
|
101
101
|
if(re._c[n+re.load.soundExt]){
|
102
102
|
//remove from array
|
103
103
|
this.total--;
|
104
|
-
|
105
|
-
|
104
|
+
continue;
|
105
|
+
} else {
|
106
|
+
this._loadSound(s, a, n);
|
106
107
|
}
|
107
|
-
|
108
|
-
|
108
|
+
} else {
|
109
|
+
//sound can't be loaded
|
110
|
+
this.total--;
|
111
|
+
continue;
|
109
112
|
}
|
110
113
|
|
111
114
|
}
|
@@ -174,43 +177,73 @@
|
|
174
177
|
}
|
175
178
|
};
|
176
179
|
|
180
|
+
/*
|
181
|
+
src - original string
|
182
|
+
a - filename
|
183
|
+
n - filename without extension
|
184
|
+
*/
|
177
185
|
p._loadSound = function(src, a, n){
|
178
|
-
var that = this;
|
186
|
+
var that = this, s;
|
179
187
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
188
|
+
if(window['soundManager']){
|
189
|
+
//use soundmanager!
|
190
|
+
|
191
|
+
soundManager.onready(function(){
|
192
|
+
|
193
|
+
s = soundManager.createSound({
|
194
|
+
id:a,
|
195
|
+
url:re.load.path+src,
|
196
|
+
autoLoad:true,
|
197
|
+
onload:function(){
|
198
|
+
that._loaded();
|
199
|
+
}
|
200
|
+
});
|
201
|
+
|
202
|
+
that._def_sfx(s, a, n);
|
184
203
|
|
185
|
-
|
186
|
-
//create statics codec for easy use
|
187
|
-
.alias(n+re.load.soundExt)
|
188
|
-
.statics({
|
189
|
-
sound:s
|
190
|
-
})
|
191
|
-
.defines({
|
192
|
-
_sound:s
|
193
|
-
});
|
204
|
+
});
|
194
205
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
s.removeEventListener('canplaythrough', f);
|
201
|
-
};
|
206
|
+
} else {
|
207
|
+
s = new Audio(re.load.path+src);
|
208
|
+
s.src = re.load.path+src;
|
209
|
+
s.preload = "auto";
|
210
|
+
s.load();
|
202
211
|
|
203
|
-
|
204
|
-
|
205
|
-
|
212
|
+
//called multiple times in firefox
|
213
|
+
var f = function(){
|
214
|
+
that._loaded();
|
215
|
+
//remove after first call
|
216
|
+
s.removeEventListener('canplaythrough', f);
|
217
|
+
};
|
206
218
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
219
|
+
s.addEventListener('canplaythrough',f,false);
|
220
|
+
|
221
|
+
s.addEventListener('error',function(){
|
222
|
+
|
223
|
+
if(that._e){
|
224
|
+
that._e.call(that, a);
|
225
|
+
}
|
226
|
+
},false);
|
227
|
+
|
228
|
+
this._def_sfx(s, a, n);
|
229
|
+
|
230
|
+
}
|
211
231
|
|
212
232
|
}
|
213
233
|
|
234
|
+
p._def_sfx = function(s, a, n){
|
235
|
+
|
236
|
+
re.c(a)
|
237
|
+
//create statics codec for easy use
|
238
|
+
.alias(n+re.load.soundExt)
|
239
|
+
.statics({
|
240
|
+
sound:s
|
241
|
+
})
|
242
|
+
.defines({
|
243
|
+
_sound:s
|
244
|
+
});
|
245
|
+
}
|
246
|
+
|
214
247
|
p.progress = function(m){
|
215
248
|
|
216
249
|
this._p = m;
|
data/src/core/re.js
CHANGED
@@ -19,15 +19,8 @@ re._e = [];
|
|
19
19
|
re._c = {};
|
20
20
|
|
21
21
|
re.ready = function(r){
|
22
|
-
re.
|
23
|
-
|
24
|
-
window.onload = function(){
|
25
|
-
for(var k in re.ready.c){
|
26
|
-
re.ready.c[k].call(re);
|
27
|
-
}
|
28
|
-
};
|
22
|
+
re.listener('load', r);
|
29
23
|
};
|
30
|
-
re.ready.c = [];
|
31
24
|
|
32
25
|
/*
|
33
26
|
The $ method is used for selecting ids and tags.
|
@@ -46,11 +39,7 @@ re.$new = function(n){
|
|
46
39
|
Special polyfills and object additions
|
47
40
|
*/
|
48
41
|
re.listener = function(t, c){
|
49
|
-
|
50
|
-
window.addEventListener(t, c, true);
|
51
|
-
} else {
|
52
|
-
document.attachEvent('on'+t, c);
|
53
|
-
}
|
42
|
+
window.addEventListener(t, c, true);
|
54
43
|
};
|
55
44
|
|
56
45
|
/*
|
@@ -60,15 +49,4 @@ re.is = function(obj, type){
|
|
60
49
|
if(arguments.length==1) return obj != null;
|
61
50
|
|
62
51
|
return obj != null && Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() == type.toLowerCase();
|
63
|
-
};
|
64
|
-
|
65
|
-
if(!Array.prototype.indexOf){
|
66
|
-
Array.prototype.indexOf = function(o){
|
67
|
-
for(var i=0; i<this.length; i++){
|
68
|
-
if(this[i]==o){
|
69
|
-
return i;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
return -1;
|
73
|
-
}
|
74
|
-
}
|
52
|
+
};
|
data/src/core/system.js
CHANGED
data/src/display/align.js
CHANGED
data/src/input/keyboard.js
CHANGED
@@ -114,7 +114,7 @@ re.c('keyboard')
|
|
114
114
|
var that = re._c.keyboard;
|
115
115
|
|
116
116
|
//disable keyboard keys if focus lost
|
117
|
-
if(
|
117
|
+
if(re.is(document.activeElement, 'htmlinputelement') || re.is(document.activeElement, 'htmltextareaelement')){
|
118
118
|
return;
|
119
119
|
}
|
120
120
|
|
@@ -136,7 +136,6 @@ re.c('keyboard')
|
|
136
136
|
|
137
137
|
//initialize function
|
138
138
|
i:function(){
|
139
|
-
this.body = re.$('body');
|
140
139
|
re.listener('keydown', this.event, false);
|
141
140
|
re.listener('keyup', this.event, false);
|
142
141
|
}
|
data/src/input/mouse.js
CHANGED
data/src/math/tile.js
CHANGED