entityjs 0.2.2 → 0.3.0
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 +7 -6
- data/.rspec +2 -0
- data/README.md +170 -49
- data/Rakefile +9 -0
- data/bin/entityjs +24 -14
- data/entityjs.gemspec +15 -9
- data/lib/entityjs/assets.rb +167 -0
- data/lib/entityjs/command.rb +52 -27
- data/lib/entityjs/commands/build.rb +128 -0
- data/lib/entityjs/commands/comp.rb +74 -0
- data/lib/entityjs/commands/font.rb +73 -0
- data/lib/entityjs/commands/new.rb +59 -0
- data/lib/entityjs/commands/server.rb +54 -0
- data/lib/entityjs/commands/templates.rb +28 -0
- data/lib/entityjs/commands/test.rb +69 -0
- data/lib/entityjs/config.rb +130 -0
- data/lib/entityjs/dirc.rb +184 -0
- data/lib/entityjs/parsers/parse_tmx.rb +41 -0
- data/lib/entityjs/parsers/parse_xml.rb +39 -0
- data/lib/entityjs/version.rb +1 -1
- data/lib/entityjs.rb +53 -0
- data/license.txt +1 -1
- data/public/play.html +122 -0
- data/public/qunit/qunit.css +226 -0
- data/public/qunit/qunit.entity.js +190 -0
- data/public/qunit/qunit.input.js +200 -0
- data/public/qunit/qunit.js +1598 -0
- data/public/qunit/qunit.mock.js +97 -0
- data/public/tests.html +45 -0
- data/spec/javascripts/helpers/accept.png +0 -0
- data/spec/javascripts/helpers/alligator.mp3 +0 -0
- data/spec/javascripts/helpers/alligator.ogg +0 -0
- data/spec/javascripts/helpers/canvas.js +15 -0
- data/spec/javascripts/helpers/entityunit.js +50 -0
- data/spec/javascripts/helpers/factories.js +11 -0
- data/spec/javascripts/helpers/jquery-1.7.1.min.js +4 -0
- data/spec/javascripts/src/core/comp_spec.js +145 -0
- data/spec/javascripts/src/core/entity_spec.js +324 -0
- data/spec/javascripts/src/core/load_spec.js +71 -0
- data/spec/javascripts/src/core/query_spec.js +157 -0
- data/spec/javascripts/src/core/re_spec.js +61 -0
- data/spec/javascripts/src/core/system_spec.js +41 -0
- data/spec/javascripts/src/cycle/draw_spec.js +106 -0
- data/spec/javascripts/src/cycle/tick_spec.js +20 -0
- data/spec/javascripts/src/cycle/update_spec.js +86 -0
- data/spec/javascripts/src/display/align_spec.js +43 -0
- data/spec/javascripts/src/display/circle_spec.js +26 -0
- data/spec/javascripts/src/display/group_spec.js +7 -0
- data/spec/javascripts/src/display/image_spec.js +32 -0
- data/spec/javascripts/src/display/imgtext_spec.js +32 -0
- data/spec/javascripts/src/display/rect_spec.js +13 -0
- data/spec/javascripts/src/display/screen_spec.js +47 -0
- data/spec/javascripts/src/display/sprite_spec.js +28 -0
- data/spec/javascripts/src/display/text_spec.js +30 -0
- data/spec/javascripts/src/input/keyboard_spec.js +67 -0
- data/spec/javascripts/src/input/mouse_spec.js +133 -0
- data/spec/javascripts/src/input/pressed_spec.js +31 -0
- data/spec/javascripts/src/math/bisect_spec.js +59 -0
- data/spec/javascripts/src/math/body_spec.js +30 -0
- data/spec/javascripts/src/math/drag_spec.js +38 -0
- data/spec/javascripts/src/math/force_spec.js +134 -0
- data/spec/javascripts/src/math/hit_spec.js +28 -0
- data/spec/javascripts/src/math/hitmap_spec.js +52 -0
- data/spec/javascripts/src/math/limit_spec.js +35 -0
- data/spec/javascripts/src/math/point_spec.js +57 -0
- data/spec/javascripts/src/math/tile_spec.js +78 -0
- data/spec/javascripts/src/media/sound_spec.js +40 -0
- data/spec/javascripts/src/pattern/automap_spec.js +93 -0
- data/spec/javascripts/src/pattern/flicker_spec.js +66 -0
- data/spec/javascripts/src/pattern/timestep_spec.js +23 -0
- data/spec/javascripts/src/save/storage_spec.js +37 -0
- data/spec/javascripts/src/util/log_spec.js +9 -0
- data/spec/javascripts/src/util/polyfill_spec.js +13 -0
- data/spec/javascripts/src/util/random_spec.js +33 -0
- data/spec/javascripts/src/util/scene_spec.js +52 -0
- data/spec/javascripts/src/util/sheet_spec.js +25 -0
- data/spec/javascripts/src/util/support_spec.js +17 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/javascripts/support/jasmine_config.rb +32 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/lib/entityjs/assets_spec.rb +216 -0
- data/spec/lib/entityjs/command_spec.rb +53 -0
- data/spec/lib/entityjs/commands/build_spec.rb +69 -0
- data/spec/lib/entityjs/commands/comp_spec.rb +45 -0
- data/spec/lib/entityjs/commands/font_spec.rb +7 -0
- data/spec/lib/entityjs/commands/new_spec.rb +20 -0
- data/spec/lib/entityjs/commands/templates_spec.rb +9 -0
- data/spec/lib/entityjs/commands/test_spec.rb +31 -0
- data/spec/lib/entityjs/config_spec.rb +19 -0
- data/spec/lib/entityjs/dirc_spec.rb +83 -0
- data/spec/lib/entityjs/version_spec.rb +9 -0
- data/spec/spec_helper.rb +21 -3
- data/spec/support/factories.rb +19 -0
- data/spec/support/mygame.rb +11 -0
- data/src/core/comp.js +318 -0
- data/src/core/entity.js +549 -0
- data/src/core/load.js +242 -0
- data/src/core/query.js +354 -0
- data/src/core/re.js +74 -0
- data/src/core/system.js +121 -0
- data/src/cycle/draw.js +178 -0
- data/src/cycle/tick.js +25 -0
- data/src/{entityjs/cycle → cycle}/tween.js +60 -60
- data/src/{entityjs/cycle → cycle}/update.js +86 -85
- data/src/{entityjs/cycle → cycle}/wait.js +22 -21
- data/src/{entityjs/cycle → cycle}/worker.js +8 -8
- data/src/display/align.js +45 -0
- data/src/display/circle.js +33 -0
- data/src/{entityjs/display → display}/group.js +62 -62
- data/src/display/image.js +35 -0
- data/src/display/imgtext.js +102 -0
- data/src/{entityjs/display → display}/rect.js +18 -18
- data/src/display/screen.js +57 -0
- data/src/display/sprite.js +54 -0
- data/src/display/text.js +44 -0
- data/src/{entityjs/input → input}/keyboard.js +152 -150
- data/src/input/mouse.js +111 -0
- data/src/input/pressed.js +41 -0
- data/src/{entityjs/input → input}/touch.js +24 -28
- data/src/math/bisect.js +84 -0
- data/src/math/body.js +70 -0
- data/src/{entityjs/math → math}/drag.js +44 -38
- data/src/math/force.js +143 -0
- data/src/math/hit.js +32 -0
- data/src/math/hitmap.js +167 -0
- data/src/math/limit.js +37 -0
- data/src/math/point.js +40 -0
- data/src/math/tile.js +109 -0
- data/src/media/channel.js +93 -0
- data/src/{entityjs/media → media}/playlist.js +4 -4
- data/src/media/sound.js +114 -0
- data/src/{entityjs/net → net}/socket.js +51 -51
- data/src/pattern/automap.js +133 -0
- data/src/{entityjs/pattern → pattern}/flicker.js +206 -213
- data/src/pattern/timestep.js +31 -0
- data/src/{entityjs/save → save}/database.js +6 -6
- data/src/{entityjs/save → save}/storage.js +47 -56
- data/src/{entityjs/util → util}/log.js +17 -25
- data/src/{entityjs/util → util}/polyfill.js +24 -24
- data/src/util/random.js +20 -0
- data/src/util/scene.js +102 -0
- data/src/util/sheet.js +35 -0
- data/src/{entityjs/util → util}/support.js +109 -132
- data/{examples/keys → templates/arrow_keys/assets/images}/arrow.png +0 -0
- data/templates/arrow_keys/config.yml +22 -0
- data/templates/arrow_keys/readme.txt +9 -0
- data/templates/arrow_keys/scripts/display/arrow.js +69 -0
- data/templates/arrow_keys/scripts/init.js +10 -0
- data/templates/arrow_keys/scripts/input/controls.js +35 -0
- data/templates/arrow_keys/scripts/scenes/home.js +20 -0
- data/templates/arrow_keys/scripts/scenes/load.js +57 -0
- data/templates/arrow_keys/tests/display/arrow_test.js +29 -0
- data/templates/arrow_keys/tests/init_test.js +4 -0
- data/templates/arrow_keys/tests/input/controls_test.js +32 -0
- data/templates/arrow_keys/tests/scenes/home_test.js +0 -0
- data/templates/arrow_keys/tests/scenes/load_test.js +16 -0
- data/templates/blank/config.yml +22 -0
- data/templates/blank/readme.txt +79 -0
- data/templates/platform/assets/images/bit.png +0 -0
- data/templates/platform/assets/images/hero.png +0 -0
- data/templates/platform/assets/images/items.png +0 -0
- data/templates/platform/assets/images/tiles.png +0 -0
- data/templates/platform/assets/levels/level1.tmx +44 -0
- data/templates/platform/assets/sounds/coin.mp3 +0 -0
- data/templates/platform/assets/sounds/coin.ogg +0 -0
- data/templates/platform/config.yml +22 -0
- data/templates/platform/readme.txt +87 -0
- data/templates/platform/scripts/display/bit.js +12 -0
- data/templates/platform/scripts/display/hero.js +77 -0
- data/templates/platform/scripts/display/tile.js +2 -0
- data/templates/platform/scripts/display/tsprite.js +17 -0
- data/templates/platform/scripts/init.js +7 -0
- data/templates/platform/scripts/items/coin.js +27 -0
- data/templates/platform/scripts/items/item.js +41 -0
- data/templates/platform/scripts/items/spring.js +25 -0
- data/templates/platform/scripts/scenes/home.js +10 -0
- data/templates/platform/scripts/scenes/load.js +27 -0
- data/templates/platform/scripts/scenes/play.js +31 -0
- data/templates/platform/scripts/util/counter.js +34 -0
- data/templates/platform/scripts/util/level.js +84 -0
- data/templates/platform/tests/display/bit_test.js +7 -0
- data/templates/platform/tests/display/hero_test.js +73 -0
- data/templates/platform/tests/display/tile_test.js +7 -0
- data/templates/platform/tests/display/tsprite_test.js +8 -0
- data/templates/platform/tests/factories.js +30 -0
- data/templates/platform/tests/items/coin_test.js +28 -0
- data/templates/platform/tests/items/item_test.js +36 -0
- data/templates/platform/tests/items/spring_test.js +21 -0
- data/templates/platform/tests/scenes/home_test.js +9 -0
- data/templates/platform/tests/scenes/load_test.js +11 -0
- data/templates/platform/tests/scenes/play_test.js +15 -0
- data/templates/platform/tests/util/counter_test.js +9 -0
- data/templates/platform/tests/util/level_test.js +29 -0
- metadata +249 -97
- data/build/build_debug.bat +0 -1
- data/build/build_min.bat +0 -1
- data/build/config.php +0 -64
- data/build/debug.php +0 -48
- data/build/files.php +0 -74
- data/build/jsmin.php +0 -376
- data/build/min.php +0 -50
- data/changelog.txt +0 -53
- data/examples/keys/keys.html +0 -59
- data/examples/keys/keys.js +0 -148
- data/examples/mouse/mouse.html +0 -58
- data/examples/mouse/mouse.js +0 -60
- data/examples/scenes/home.png +0 -0
- data/examples/scenes/scenes.html +0 -55
- data/examples/scenes/scenes.js +0 -134
- data/examples/scenes/win.png +0 -0
- data/examples/sounds/sound1.mp3 +0 -0
- data/examples/sounds/sound1.ogg +0 -0
- data/examples/sounds/sounds.html +0 -56
- data/examples/sounds/sounds.js +0 -44
- data/examples/style/background.png +0 -0
- data/examples/style/sheet.css +0 -762
- data/examples/tiles/tiles.html +0 -56
- data/examples/tiles/tiles.js +0 -85
- data/examples/tiles/tiles.png +0 -0
- data/lib/blank/config.js +0 -4
- data/lib/blank/config.yml +0 -21
- data/lib/blank/home.js +0 -11
- data/lib/blank/init.js +0 -7
- data/lib/blank/load.js +0 -21
- data/lib/blank/play.html +0 -29
- data/lib/entity.debug.js +0 -52
- data/lib/entity.min.js +0 -184
- data/lib/entityjs/comp.rb +0 -11
- data/lib/entityjs/game.rb +0 -93
- data/lib/entityjs/min.rb +0 -11
- data/lib/entityjs/refresh.rb +0 -14
- data/spec/lib/entityjs/game_spec.rb +0 -11
- data/src/entityjs/core/component.js +0 -306
- data/src/entityjs/core/entity.js +0 -516
- data/src/entityjs/core/load.js +0 -224
- data/src/entityjs/core/query.js +0 -410
- data/src/entityjs/core/re.js +0 -70
- data/src/entityjs/core/system.js +0 -125
- data/src/entityjs/cycle/draw.js +0 -185
- data/src/entityjs/cycle/ticker.js +0 -27
- data/src/entityjs/display/anchor.js +0 -53
- data/src/entityjs/display/bitfont.js +0 -93
- data/src/entityjs/display/bitmap.js +0 -37
- data/src/entityjs/display/circle.js +0 -30
- data/src/entityjs/display/font.js +0 -41
- data/src/entityjs/display/screen.js +0 -46
- data/src/entityjs/display/sprite.js +0 -37
- data/src/entityjs/input/mouse.js +0 -123
- data/src/entityjs/input/pressed.js +0 -81
- data/src/entityjs/math/bind.js +0 -76
- data/src/entityjs/math/bisect.js +0 -69
- data/src/entityjs/math/body.js +0 -39
- data/src/entityjs/math/hitmap.js +0 -165
- data/src/entityjs/math/hittest.js +0 -26
- data/src/entityjs/math/physics.js +0 -142
- data/src/entityjs/math/point.js +0 -57
- data/src/entityjs/math/tile.js +0 -91
- data/src/entityjs/media/channel.js +0 -93
- data/src/entityjs/media/sound.js +0 -110
- data/src/entityjs/pattern/arraymap.js +0 -89
- data/src/entityjs/pattern/timestep.js +0 -34
- data/src/entityjs/util/random.js +0 -38
- data/src/entityjs/util/scene.js +0 -101
- data/src/entityjs/util/sheet.js +0 -51
|
@@ -1,214 +1,207 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The flicker component calls the implemented method and sends the given information over a period of time.
|
|
3
|
-
|
|
4
|
-
This is most popular for sprite animation.
|
|
5
|
-
|
|
6
|
-
It can also be used for graduatly writing text or flashing a drawing object.
|
|
7
|
-
*/
|
|
8
|
-
re.c('flicker')
|
|
9
|
-
.
|
|
10
|
-
.
|
|
11
|
-
.init(function(){
|
|
12
|
-
|
|
13
|
-
this.flicker_reels = {};
|
|
14
|
-
this.flicker_old = {};
|
|
15
|
-
this.flicker_reel = {};
|
|
16
|
-
|
|
17
|
-
this.flicker_flickering = '';
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
flicker_stop:function(){
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
c.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
this.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if(id){
|
|
208
|
-
return this.flicker_flickering == id;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return this.flicker_flickering != '';
|
|
212
|
-
}
|
|
213
|
-
|
|
1
|
+
/*
|
|
2
|
+
The flicker component calls the implemented method and sends the given information over a period of time.
|
|
3
|
+
|
|
4
|
+
This is most popular for sprite animation.
|
|
5
|
+
|
|
6
|
+
It can also be used for graduatly writing text or flashing a drawing object.
|
|
7
|
+
*/
|
|
8
|
+
re.c('flicker')
|
|
9
|
+
.requires('update timestep')
|
|
10
|
+
.interfaces('flick')
|
|
11
|
+
.init(function(){
|
|
12
|
+
|
|
13
|
+
this.flicker_reels = {};
|
|
14
|
+
this.flicker_old = {};
|
|
15
|
+
this.flicker_reel = {};
|
|
16
|
+
|
|
17
|
+
this.flicker_flickering = '';
|
|
18
|
+
|
|
19
|
+
})
|
|
20
|
+
.defines({
|
|
21
|
+
|
|
22
|
+
flicker_stop:function(){
|
|
23
|
+
var o = this.flicker_flickering;
|
|
24
|
+
this.flicker_flickering = '';
|
|
25
|
+
|
|
26
|
+
this.stepProgress = 0;
|
|
27
|
+
|
|
28
|
+
this.off('update', this.flicker_update);
|
|
29
|
+
|
|
30
|
+
return this.trigger('flicker:end', o);
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
flicker_update:function(t){
|
|
34
|
+
|
|
35
|
+
this.timestep(t, function(){
|
|
36
|
+
var c = this.flicker_reel;
|
|
37
|
+
|
|
38
|
+
//check if over
|
|
39
|
+
if(this.flicker_frame == this.flicker_reel.frames.length){
|
|
40
|
+
|
|
41
|
+
if(c.loops == -1 || --this.flicker_loops >= 1){
|
|
42
|
+
//loop again
|
|
43
|
+
|
|
44
|
+
this.flicker_frame = 0;
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
//done flickering
|
|
48
|
+
|
|
49
|
+
this.flicker_stop();
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//flick
|
|
56
|
+
if(this.flick(c.frames[this.flicker_frame], this.flicker_flickering, this.flicker_loops) === false){
|
|
57
|
+
//stop
|
|
58
|
+
this.flicker();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.flicker_frame++;
|
|
62
|
+
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
addFlicker:function(id, loops, duration, frames){
|
|
68
|
+
|
|
69
|
+
if(re.is(id, 'object')){
|
|
70
|
+
|
|
71
|
+
for(var i in id){
|
|
72
|
+
if(!id.hasOwnProperty(i)) continue;
|
|
73
|
+
|
|
74
|
+
//copy formed array and insert
|
|
75
|
+
var c = id[i].slice();
|
|
76
|
+
//add key into array
|
|
77
|
+
c.unshift(i);
|
|
78
|
+
|
|
79
|
+
this.addFlicker.apply(this, c);
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if(re.is(frames, 'string')) frames = frames.split(' ');
|
|
87
|
+
|
|
88
|
+
//add
|
|
89
|
+
this.flicker_reels[id] =
|
|
90
|
+
{
|
|
91
|
+
frames:frames,
|
|
92
|
+
duration:duration,
|
|
93
|
+
loops:loops
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return this;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
removeFlicker:function(id){
|
|
100
|
+
|
|
101
|
+
if(re.is(id,'object')){
|
|
102
|
+
|
|
103
|
+
for(var i in id){
|
|
104
|
+
if(!id.hasOwnProperty(i)) continue;
|
|
105
|
+
|
|
106
|
+
this.removeFlicker.call(this, id[i]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//assuming this flicker isn't running
|
|
113
|
+
delete this.flicker_reels[id];
|
|
114
|
+
|
|
115
|
+
return this;
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
The animate method either creates or plays an animation.
|
|
120
|
+
Time is in milliseconds.
|
|
121
|
+
|
|
122
|
+
//create sequence animation
|
|
123
|
+
re('#player').flicker('die', 1, 200, [0, 1, 3, 3, 4, 3, 2, 1]);
|
|
124
|
+
|
|
125
|
+
//play animation
|
|
126
|
+
//can customize the animation for this call.
|
|
127
|
+
re('#player').flicker('die', 0, 200);
|
|
128
|
+
|
|
129
|
+
//stop flickering
|
|
130
|
+
re('#player').flicker();
|
|
131
|
+
|
|
132
|
+
//add multiple animations
|
|
133
|
+
flicker({
|
|
134
|
+
idle:[loops, duration, frames],
|
|
135
|
+
..
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
FUTURE:
|
|
141
|
+
-allow backward animations
|
|
142
|
+
-allow entry of an array of frames. So each counter will go to the next frame in the array
|
|
143
|
+
*/
|
|
144
|
+
flicker:function(id, loops, duration, frames){
|
|
145
|
+
|
|
146
|
+
if(!re.is(id) && this.flickering()){
|
|
147
|
+
//stop flickering
|
|
148
|
+
return this.flicker_stop();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if(id == this.flicker_flickering) return;
|
|
152
|
+
|
|
153
|
+
if(!this.flicker_reels[id]){
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//defaults
|
|
158
|
+
|
|
159
|
+
//startX = loops, endX = duration in seconds
|
|
160
|
+
//if startX equals 0, animation loops forever
|
|
161
|
+
|
|
162
|
+
var r = this.flicker_reels[id];
|
|
163
|
+
|
|
164
|
+
//create new reel based on custom attributes
|
|
165
|
+
var c = this.flicker_reel;
|
|
166
|
+
//copy from saved animation or newly given
|
|
167
|
+
c.loops = (isNaN(loops))? r.loops : loops;
|
|
168
|
+
c.duration = (isNaN(duration))? r.duration : duration;
|
|
169
|
+
c.frames = (re.is(frames,'object'))? frames : r.frames;
|
|
170
|
+
|
|
171
|
+
//setup counter for loops
|
|
172
|
+
this.flicker_loops = c.loops;
|
|
173
|
+
|
|
174
|
+
this.stepProgress = 0;
|
|
175
|
+
this.stepSize = c.duration / c.frames.length / 1000;
|
|
176
|
+
|
|
177
|
+
//save old frames for upon completion
|
|
178
|
+
|
|
179
|
+
this.flicker_frame = 0;
|
|
180
|
+
|
|
181
|
+
//update frame then run
|
|
182
|
+
this.flick(c.frames[this.flicker_frame++]);
|
|
183
|
+
|
|
184
|
+
if(!this.flickering()){
|
|
185
|
+
this.on('update', this.flicker_update);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
this.flicker_flickering = id;
|
|
189
|
+
|
|
190
|
+
return this.trigger('flicker:start');
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
Check if flicker is running / compare current.
|
|
195
|
+
|
|
196
|
+
this.flickering(); // returns current flicker name
|
|
197
|
+
this.flickering('idle'); // false
|
|
198
|
+
*/
|
|
199
|
+
flickering:function(id){
|
|
200
|
+
if(id){
|
|
201
|
+
return this.flicker_flickering == id;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return this.flicker_flickering;
|
|
205
|
+
}
|
|
206
|
+
|
|
214
207
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The timestep component gathers steps over time and once the maximum steps
|
|
3
|
+
are achieved it will dispatch the callback method. This method is also delta time
|
|
4
|
+
safe, so you don't need to worry about alternate values over time.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
re.c('timestep')
|
|
10
|
+
.defaults({
|
|
11
|
+
|
|
12
|
+
stepProgress:0,
|
|
13
|
+
stepSize:100
|
|
14
|
+
|
|
15
|
+
})
|
|
16
|
+
.defines({
|
|
17
|
+
|
|
18
|
+
timestep:function(progress, callback, context){
|
|
19
|
+
|
|
20
|
+
this.stepProgress += progress;
|
|
21
|
+
|
|
22
|
+
while(this.stepProgress >= this.stepSize){
|
|
23
|
+
|
|
24
|
+
callback.call((context)?context:this);
|
|
25
|
+
|
|
26
|
+
this.stepProgress -= this.stepSize;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The database component adds functions for creating and dealing with databases.
|
|
3
|
-
This will reference only one database.
|
|
4
|
-
|
|
5
|
-
Because of the current stance of firefox. I'm not sure if its safe implementing this yet.
|
|
6
|
-
*//*
|
|
1
|
+
/*
|
|
2
|
+
The database component adds functions for creating and dealing with databases.
|
|
3
|
+
This will reference only one database.
|
|
4
|
+
|
|
5
|
+
Because of the current stance of firefox. I'm not sure if its safe implementing this yet.
|
|
6
|
+
*//*
|
|
7
7
|
re.c('database');*/
|
|
@@ -1,57 +1,48 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The storage component contains methods for storing locally or session values.
|
|
3
|
-
This utilizes the new HTML5 localstorage and sessionstorage.
|
|
4
|
-
|
|
5
|
-
//create new local storage
|
|
6
|
-
re.e('storage:local');
|
|
7
|
-
|
|
8
|
-
//create new session storage
|
|
9
|
-
re.e('storage:session');
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
re.c('storage')
|
|
13
|
-
.init(function(c, type){
|
|
14
|
-
this.storage =
|
|
15
|
-
})
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
length:function(){
|
|
19
|
-
return this.storage.length;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
key:function(index){
|
|
23
|
-
return this.storage.key(index);
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return this;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
clear:function(){
|
|
52
|
-
this.storage.clear();
|
|
53
|
-
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
1
|
+
/*
|
|
2
|
+
The storage component contains methods for storing locally or session values.
|
|
3
|
+
This utilizes the new HTML5 localstorage and sessionstorage.
|
|
4
|
+
|
|
5
|
+
//create new local storage
|
|
6
|
+
re.e('storage:local');
|
|
7
|
+
|
|
8
|
+
//create new session storage
|
|
9
|
+
re.e('storage:session');
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
re.c('storage')
|
|
13
|
+
.init(function(c, type){
|
|
14
|
+
this.storage = window[type+'Storage'];
|
|
15
|
+
})
|
|
16
|
+
.defines({
|
|
17
|
+
|
|
18
|
+
length:function(){
|
|
19
|
+
return this.storage.length;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
key:function(index){
|
|
23
|
+
return this.storage.key(index);
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
item:function(key, data){
|
|
27
|
+
|
|
28
|
+
if(!re.is(data)){
|
|
29
|
+
return JSON.parse(this.storage.getItem(key));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.storage.setItem(key, JSON.stringify(data));
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
removeItem:function(key){
|
|
38
|
+
this.storage.removeItem(key);
|
|
39
|
+
return this;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
clear:function(){
|
|
43
|
+
this.storage.clear();
|
|
44
|
+
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
57
48
|
})
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The log component
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} catch(e){
|
|
19
|
-
alert(Array.prototype.join.call(arguments, " "));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
re.c('log')
|
|
25
|
-
.extend('log', re.log);
|
|
1
|
+
/*
|
|
2
|
+
The log component definess a cross browser console.log command.
|
|
3
|
+
|
|
4
|
+
re.log('example log');
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
re.log = function(){
|
|
8
|
+
try{
|
|
9
|
+
console.log.apply(console, arguments);
|
|
10
|
+
} catch(e){
|
|
11
|
+
try {
|
|
12
|
+
opera.postError.apply(opera, arguments);
|
|
13
|
+
} catch(e){
|
|
14
|
+
alert(Array.prototype.join.call(arguments, " "));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The polyfill component polyfills unsupported HTML5 functions when possible.
|
|
3
|
-
*/
|
|
4
|
-
re.c('polyfill')
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
requestAnimationFrame:function(callback, canvas){
|
|
8
|
-
return requestAnimFrame(callback, canvas);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
.run(function(){
|
|
13
|
-
|
|
14
|
-
//setup requestanimationframe on support
|
|
15
|
-
window.requestAnimFrame =
|
|
16
|
-
window.requestAnimationFrame ||
|
|
17
|
-
window.webkitRequestAnimationFrame ||
|
|
18
|
-
window.mozRequestAnimationFrame ||
|
|
19
|
-
window.oRequestAnimationFrame ||
|
|
20
|
-
window.msRequestAnimationFrame ||
|
|
21
|
-
function(callback){
|
|
22
|
-
window.setTimeout(callback, 1000 / 60);
|
|
23
|
-
};
|
|
24
|
-
|
|
1
|
+
/*
|
|
2
|
+
The polyfill component polyfills unsupported HTML5 functions when possible.
|
|
3
|
+
*/
|
|
4
|
+
re.c('polyfill')
|
|
5
|
+
.defines({
|
|
6
|
+
|
|
7
|
+
requestAnimationFrame:function(callback, canvas){
|
|
8
|
+
return requestAnimFrame(callback, canvas);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
})
|
|
12
|
+
.run(function(){
|
|
13
|
+
|
|
14
|
+
//setup requestanimationframe on support
|
|
15
|
+
window.requestAnimFrame =
|
|
16
|
+
window.requestAnimationFrame ||
|
|
17
|
+
window.webkitRequestAnimationFrame ||
|
|
18
|
+
window.mozRequestAnimationFrame ||
|
|
19
|
+
window.oRequestAnimationFrame ||
|
|
20
|
+
window.msRequestAnimationFrame ||
|
|
21
|
+
function(callback){
|
|
22
|
+
window.setTimeout(callback, 1000 / 60);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
25
|
});
|