melonjs 9.1.0 → 10.0.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.
Files changed (78) hide show
  1. package/{LICENSE → LICENSE.md} +0 -0
  2. package/README.md +93 -57
  3. package/dist/melonjs.js +10334 -11179
  4. package/dist/melonjs.min.js +4 -10
  5. package/dist/melonjs.module.d.ts +13206 -0
  6. package/dist/melonjs.module.js +9913 -10872
  7. package/package.json +19 -14
  8. package/src/audio/audio.js +477 -553
  9. package/src/camera/camera2d.js +67 -65
  10. package/src/entity/draggable.js +26 -35
  11. package/src/entity/droptarget.js +17 -14
  12. package/src/entity/entity.js +59 -79
  13. package/src/game.js +194 -204
  14. package/src/index.js +12 -30
  15. package/src/input/gamepad.js +8 -19
  16. package/src/input/keyboard.js +4 -4
  17. package/src/input/pointer.js +14 -12
  18. package/src/input/pointerevent.js +15 -13
  19. package/src/lang/deprecated.js +2 -887
  20. package/src/level/level.js +3 -3
  21. package/src/level/tiled/TMXGroup.js +7 -11
  22. package/src/level/tiled/TMXLayer.js +33 -32
  23. package/src/level/tiled/TMXTileMap.js +15 -19
  24. package/src/level/tiled/TMXTileset.js +5 -5
  25. package/src/level/tiled/TMXUtils.js +3 -3
  26. package/src/level/tiled/renderer/TMXRenderer.js +4 -0
  27. package/src/loader/loader.js +8 -23
  28. package/src/loader/loadingscreen.js +51 -60
  29. package/src/math/matrix3.js +1 -1
  30. package/src/particles/emitter.js +36 -39
  31. package/src/particles/particle.js +27 -12
  32. package/src/particles/particlecontainer.js +17 -16
  33. package/src/physics/body.js +80 -118
  34. package/src/physics/collision.js +5 -235
  35. package/src/physics/detector.js +235 -0
  36. package/src/physics/quadtree.js +14 -14
  37. package/src/physics/world.js +84 -18
  38. package/src/plugin/plugin.js +26 -24
  39. package/src/polyfill/console.js +9 -14
  40. package/src/renderable/GUI.js +48 -62
  41. package/src/renderable/collectable.js +11 -4
  42. package/src/renderable/colorlayer.js +28 -26
  43. package/src/renderable/container.js +120 -96
  44. package/src/renderable/imagelayer.js +94 -93
  45. package/src/renderable/renderable.js +164 -138
  46. package/src/renderable/sprite.js +42 -44
  47. package/src/renderable/trigger.js +24 -17
  48. package/src/shapes/ellipse.js +27 -27
  49. package/src/shapes/line.js +12 -8
  50. package/src/shapes/poly.js +77 -49
  51. package/src/shapes/rectangle.js +193 -268
  52. package/src/state/stage.js +23 -25
  53. package/src/state/state.js +35 -86
  54. package/src/system/device.js +233 -285
  55. package/src/system/event.js +485 -432
  56. package/src/system/pooling.js +61 -54
  57. package/src/system/save.js +17 -16
  58. package/src/system/timer.js +34 -38
  59. package/src/text/bitmaptext.js +44 -46
  60. package/src/text/text.js +39 -34
  61. package/src/tweens/easing.js +0 -2
  62. package/src/tweens/interpolation.js +3 -8
  63. package/src/tweens/tween.js +332 -351
  64. package/src/utils/function.js +6 -8
  65. package/src/utils/utils.js +34 -30
  66. package/src/video/canvas/canvas_renderer.js +13 -8
  67. package/src/video/renderer.js +8 -7
  68. package/src/video/texture.js +8 -8
  69. package/src/video/texture_cache.js +5 -5
  70. package/src/video/video.js +373 -403
  71. package/src/video/webgl/glshader.js +2 -2
  72. package/src/video/webgl/webgl_compositor.js +14 -8
  73. package/src/video/webgl/webgl_renderer.js +21 -19
  74. package/plugins/debug/debugPanel.js +0 -770
  75. package/plugins/debug/font/PressStart2P.fnt +0 -100
  76. package/plugins/debug/font/PressStart2P.ltr +0 -1
  77. package/plugins/debug/font/PressStart2P.png +0 -0
  78. package/plugins/debug/particleDebugPanel.js +0 -303
@@ -1,6 +1,6 @@
1
1
  import timer from "./../system/timer.js";
2
- import event from "./../system/event.js";
3
- import game from "./../game.js";
2
+ import * as event from "./../system/event.js";
3
+ import { world, lastUpdate } from "./../game.js";
4
4
  import { Easing } from "./easing.js";
5
5
  import { Interpolation } from "./interpolation.js";
6
6
 
@@ -9,9 +9,8 @@ import { Interpolation } from "./interpolation.js";
9
9
  * https://github.com/tweenjs/tween.js
10
10
  */
11
11
 
12
- /* eslint-disable quotes, keyword-spacing, comma-spacing, no-return-assign */
13
-
14
12
  /**
13
+ * @classdesc
15
14
  * Javascript Tweening Engine<p>
16
15
  * Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equation<p>
17
16
  * <a href="https://github.com/sole/Tween.js">https://github.com/sole/Tween.js</a><p>
@@ -23,7 +22,7 @@ import { Interpolation } from "./interpolation.js";
23
22
  * author Paul Lewis / http://www.aerotwist.com/<br>
24
23
  * author lechecacharro<br>
25
24
  * author Josh Faul / http://jocafa.com/
26
- * @class
25
+ * @class Tween
27
26
  * @memberOf me
28
27
  * @constructor
29
28
  * @param {Object} object object on which to apply the tween
@@ -42,454 +41,436 @@ class Tween {
42
41
 
43
42
  // constructor
44
43
  constructor ( object ) {
44
+ this.setProperties(object);
45
+ }
45
46
 
46
- var _object = null;
47
- var _valuesStart = null;
48
- var _valuesEnd = null;
49
- var _valuesStartRepeat = null;
50
- var _duration = null;
51
- var _repeat = null;
52
- var _yoyo = null;
53
- var _reversed = null;
54
- var _delayTime = null;
55
- var _startTime = null;
56
- var _easingFunction = null;
57
- var _interpolationFunction = null;
58
- var _chainedTweens = null;
59
- var _onStartCallback = null;
60
- var _onStartCallbackFired = null;
61
- var _onUpdateCallback = null;
62
- var _onCompleteCallback = null;
63
- var _tweenTimeTracker = null;
47
+ /**
48
+ * reset the tween object to default value
49
+ * @ignore
50
+ */
51
+ onResetEvent( object ) {
52
+ this.setProperties(object);
53
+ }
64
54
 
55
+ /**
56
+ * @ignore
57
+ */
58
+ setProperties(object) {
59
+ this._object = object;
60
+ this._valuesStart = {};
61
+ this._valuesEnd = {};
62
+ this._valuesStartRepeat = {};
63
+ this._duration = 1000;
64
+ this._repeat = 0;
65
+ this._yoyo = false;
66
+ this._reversed = false;
67
+ this._delayTime = 0;
68
+ this._startTime = null;
69
+ this._easingFunction = Easing.Linear.None;
70
+ this._interpolationFunction = Interpolation.Linear;
71
+ this._chainedTweens = [];
72
+ this._onStartCallback = null;
73
+ this._onStartCallbackFired = false;
74
+ this._onUpdateCallback = null;
75
+ this._onCompleteCallback = null;
76
+ // tweens are synchronized with the game update loop
77
+ this._tweenTimeTracker = lastUpdate;
78
+
79
+ // reset flags to default value
80
+ this.isPersistent = false;
81
+ // this is not really supported
82
+ this.updateWhenPaused = false;
65
83
  // comply with the container contract
66
84
  this.isRenderable = false;
67
85
 
68
- /**
69
- * @ignore
70
- */
71
- this._resumeCallback = function (elapsed) {
72
- if (_startTime) {
73
- _startTime += elapsed;
74
- }
75
- };
76
-
77
- /**
78
- * @ignore
79
- */
80
- this.setProperties = function (object) {
81
- _object = object;
82
- _valuesStart = {};
83
- _valuesEnd = {};
84
- _valuesStartRepeat = {};
85
- _duration = 1000;
86
- _repeat = 0;
87
- _yoyo = false;
88
- _reversed = false;
89
- _delayTime = 0;
90
- _startTime = null;
91
- _easingFunction = Easing.Linear.None;
92
- _interpolationFunction = Interpolation.Linear;
93
- _chainedTweens = [];
94
- _onStartCallback = null;
95
- _onStartCallbackFired = false;
96
- _onUpdateCallback = null;
97
- _onCompleteCallback = null;
98
- _tweenTimeTracker = timer.lastUpdate;
99
-
100
- // reset flags to default value
101
- this.isPersistent = false;
102
- // this is not really supported
103
- this.updateWhenPaused = false;
104
-
105
- // Set all starting values present on the target object
106
- for ( var field in object ) {
107
- if(typeof object !== 'object') {
108
- _valuesStart[ field ] = parseFloat(object[field]);
109
- }
86
+ // Set all starting values present on the target object
87
+ for ( var field in object ) {
88
+ if (typeof object !== "object") {
89
+ this._valuesStart[ field ] = parseFloat(object[field]);
110
90
  }
111
- };
91
+ }
92
+ }
112
93
 
113
- this.setProperties(object);
94
+ /**
95
+ * @ignore
96
+ */
97
+ _resumeCallback(elapsed) {
98
+ if (this._startTime) {
99
+ this._startTime += elapsed;
100
+ }
101
+ }
114
102
 
115
- /**
116
- * reset the tween object to default value
117
- * @ignore
118
- */
119
- this.onResetEvent = function ( object ) {
120
- this.setProperties(object);
121
- };
122
-
123
- /**
124
- * subscribe to the resume event when added
125
- * @ignore
126
- */
127
- this.onActivateEvent = function () {
128
- event.subscribe(event.STATE_RESUME, this._resumeCallback);
129
- };
130
-
131
- /**
132
- * Unsubscribe when tween is removed
133
- * @ignore
134
- */
135
- this.onDeactivateEvent = function () {
136
- event.unsubscribe(event.STATE_RESUME, this._resumeCallback);
137
- };
138
-
139
- /**
140
- * object properties to be updated and duration
141
- * @name me.Tween#to
142
- * @public
143
- * @function
144
- * @param {Object} properties hash of properties
145
- * @param {Object|Number} [options] object of tween properties, or a duration if a numeric value is passed
146
- * @param {Number} [options.duration] tween duration
147
- * @param {me.Tween.Easing} [options.easing] easing function
148
- * @param {Number} [options.delay] delay amount expressed in milliseconds
149
- * @param {Boolean} [options.yoyo] allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops.
150
- * @param {Number} [options.repeat] amount of times the tween should be repeated
151
- * @param {me.Tween.Interpolation} [options.interpolation] interpolation function
152
- * @param {Boolean} [options.autoStart] allow this tween to start automatically. Otherwise call me.Tween.start().
153
- */
154
- this.to = function ( properties, options ) {
155
-
156
- _valuesEnd = properties;
157
-
158
- if (typeof options !== "undefined") {
159
- if (typeof options === 'number') {
160
- // for backward compatiblity
161
- _duration = options;
162
- } else if (typeof options === 'object') {
163
- if (options.duration) { _duration = options.duration; }
164
- if (options.yoyo) { this.yoyo(options.yoyo); }
165
- if (options.easing) { this.easing(options.easing); }
166
- if (options.repeat) { this.repeat(options.repeat); }
167
- if (options.delay) { this.delay(options.delay); }
168
- if (options.interpolation) { this.interpolation(options.interpolation); }
169
-
170
- if (options.autoStart) {
171
- this.start();
172
- }
173
- }
174
- }
175
103
 
176
- return this;
177
104
 
178
- };
105
+ /**
106
+ * subscribe to the resume event when added
107
+ * @ignore
108
+ */
109
+ onActivateEvent() {
110
+ event.on(event.STATE_RESUME, this._resumeCallback, this);
111
+ }
179
112
 
180
- /**
181
- * start the tween
182
- * @name me.Tween#start
183
- * @public
184
- * @function
185
- */
186
- this.start = function ( _time ) {
113
+ /**
114
+ * Unsubscribe when tween is removed
115
+ * @ignore
116
+ */
117
+ onDeactivateEvent() {
118
+ event.off(event.STATE_RESUME, this._resumeCallback);
119
+ }
187
120
 
188
- _onStartCallbackFired = false;
121
+ /**
122
+ * object properties to be updated and duration
123
+ * @name to
124
+ * @memberOf me.Tween
125
+ * @public
126
+ * @function
127
+ * @param {Object} properties hash of properties
128
+ * @param {Object|Number} [options] object of tween properties, or a duration if a numeric value is passed
129
+ * @param {Number} [options.duration] tween duration
130
+ * @param {me.Tween.Easing} [options.easing] easing function
131
+ * @param {Number} [options.delay] delay amount expressed in milliseconds
132
+ * @param {Boolean} [options.yoyo] allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops.
133
+ * @param {Number} [options.repeat] amount of times the tween should be repeated
134
+ * @param {me.Tween.Interpolation} [options.interpolation] interpolation function
135
+ * @param {Boolean} [options.autoStart] allow this tween to start automatically. Otherwise call me.Tween.start().
136
+ */
137
+ to( properties, options ) {
138
+
139
+ this._valuesEnd = properties;
140
+
141
+ if (typeof options !== "undefined") {
142
+ if (typeof options === "number") {
143
+ // for backward compatiblity
144
+ this._duration = options;
145
+ } else if (typeof options === "object") {
146
+ if (options.duration) { this._duration = options.duration; }
147
+ if (options.yoyo) { this.yoyo(options.yoyo); }
148
+ if (options.easing) { this.easing(options.easing); }
149
+ if (options.repeat) { this.repeat(options.repeat); }
150
+ if (options.delay) { this.delay(options.delay); }
151
+ if (options.interpolation) { this.interpolation(options.interpolation); }
152
+
153
+ if (options.autoStart) {
154
+ this.start();
155
+ }
156
+ }
157
+ }
189
158
 
190
- // add the tween to the object pool on start
191
- game.world.addChild(this);
159
+ return this;
192
160
 
193
- _startTime = (typeof(_time) === 'undefined' ? timer.getTime() : _time) + _delayTime;
161
+ }
194
162
 
195
- for ( var property in _valuesEnd ) {
163
+ /**
164
+ * start the tween
165
+ * @name start
166
+ * @memberOf me.Tween
167
+ * @public
168
+ * @function
169
+ */
170
+ start( time = timer.getTime() ) {
196
171
 
197
- // check if an Array was provided as property value
198
- if ( _valuesEnd[ property ] instanceof Array ) {
172
+ this._onStartCallbackFired = false;
199
173
 
200
- if ( _valuesEnd[ property ].length === 0 ) {
174
+ // add the tween to the object pool on start
175
+ world.addChild(this);
201
176
 
202
- continue;
177
+ this._startTime = time + this._delayTime;
203
178
 
204
- }
179
+ for ( var property in this._valuesEnd ) {
205
180
 
206
- // create a local copy of the Array with the start value at the front
207
- _valuesEnd[ property ] = [ _object[ property ] ].concat( _valuesEnd[ property ] );
181
+ // check if an Array was provided as property value
182
+ if ( this._valuesEnd[ property ] instanceof Array ) {
208
183
 
209
- }
184
+ if ( this._valuesEnd[ property ].length === 0 ) {
210
185
 
211
- _valuesStart[ property ] = _object[ property ];
186
+ continue;
212
187
 
213
- if( ( _valuesStart[ property ] instanceof Array ) === false ) {
214
- _valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
215
188
  }
216
189
 
217
- _valuesStartRepeat[ property ] = _valuesStart[ property ] || 0;
190
+ // create a local copy of the Array with the start value at the front
191
+ this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] );
218
192
 
219
193
  }
220
194
 
221
- return this;
222
-
223
- };
224
-
225
- /**
226
- * stop the tween
227
- * @name me.Tween#stop
228
- * @public
229
- * @function
230
- */
231
- this.stop = function () {
232
- // remove the tween from the world container
233
- game.world.removeChildNow(this);
234
- return this;
235
- };
236
-
237
- /**
238
- * delay the tween
239
- * @name me.Tween#delay
240
- * @public
241
- * @function
242
- * @param {Number} amount delay amount expressed in milliseconds
243
- */
244
- this.delay = function ( amount ) {
245
-
246
- _delayTime = amount;
247
- return this;
248
-
249
- };
250
-
251
- /**
252
- * Repeat the tween
253
- * @name me.Tween#repeat
254
- * @public
255
- * @function
256
- * @param {Number} times amount of times the tween should be repeated
257
- */
258
- this.repeat = function ( times ) {
259
-
260
- _repeat = times;
261
- return this;
262
-
263
- };
264
-
265
- /**
266
- * Allows the tween to bounce back to their original value when finished.
267
- * To be used together with repeat to create endless loops.
268
- * @name me.Tween#yoyo
269
- * @public
270
- * @function
271
- * @see me.Tween#repeat
272
- * @param {Boolean} yoyo
273
- */
274
- this.yoyo = function( yoyo ) {
275
-
276
- _yoyo = yoyo;
277
- return this;
278
-
279
- };
280
-
281
- /**
282
- * set the easing function
283
- * @name me.Tween#easing
284
- * @public
285
- * @function
286
- * @param {me.Tween.Easing} fn easing function
287
- */
288
- this.easing = function ( easing ) {
289
- if (typeof easing !== 'function') {
290
- throw new Error("invalid easing function for me.Tween.easing()");
195
+ this._valuesStart[ property ] = this._object[ property ];
196
+
197
+ if ( ( this._valuesStart[ property ] instanceof Array ) === false ) {
198
+ this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
291
199
  }
292
- _easingFunction = easing;
293
- return this;
294
200
 
295
- };
201
+ this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0;
296
202
 
297
- /**
298
- * set the interpolation function
299
- * @name me.Tween#interpolation
300
- * @public
301
- * @function
302
- * @param {me.Tween.Interpolation} fn interpolation function
303
- */
304
- this.interpolation = function ( interpolation ) {
203
+ }
305
204
 
306
- _interpolationFunction = interpolation;
307
- return this;
205
+ return this;
308
206
 
309
- };
207
+ }
310
208
 
311
- /**
312
- * chain the tween
313
- * @name me.Tween#chain
314
- * @public
315
- * @function
316
- * @param {me.Tween} chainedTween Tween to be chained
317
- */
318
- this.chain = function () {
209
+ /**
210
+ * stop the tween
211
+ * @name stop
212
+ * @memberOf me.Tween
213
+ * @public
214
+ * @function
215
+ */
216
+ stop() {
217
+ // remove the tween from the world container
218
+ world.removeChildNow(this);
219
+ return this;
220
+ }
319
221
 
320
- _chainedTweens = arguments;
321
- return this;
222
+ /**
223
+ * delay the tween
224
+ * @name delay
225
+ * @memberOf me.Tween
226
+ * @public
227
+ * @function
228
+ * @param {Number} amount delay amount expressed in milliseconds
229
+ */
230
+ delay( amount ) {
322
231
 
323
- };
232
+ this._delayTime = amount;
233
+ return this;
324
234
 
325
- /**
326
- * onStart callback
327
- * @name me.Tween#onStart
328
- * @public
329
- * @function
330
- * @param {Function} onStartCallback callback
331
- */
332
- this.onStart = function ( callback ) {
235
+ }
333
236
 
334
- _onStartCallback = callback;
335
- return this;
237
+ /**
238
+ * Repeat the tween
239
+ * @name repeat
240
+ * @memberOf me.Tween
241
+ * @public
242
+ * @function
243
+ * @param {Number} times amount of times the tween should be repeated
244
+ */
245
+ repeat( times ) {
336
246
 
337
- };
247
+ this._repeat = times;
248
+ return this;
338
249
 
339
- /**
340
- * onUpdate callback
341
- * @name me.Tween#onUpdate
342
- * @public
343
- * @function
344
- * @param {Function} onUpdateCallback callback
345
- */
346
- this.onUpdate = function ( callback ) {
250
+ }
347
251
 
348
- _onUpdateCallback = callback;
349
- return this;
252
+ /**
253
+ * Allows the tween to bounce back to their original value when finished.
254
+ * To be used together with repeat to create endless loops.
255
+ * @name yoyo
256
+ * @memberOf me.Tween
257
+ * @public
258
+ * @function
259
+ * @see me.Tween#repeat
260
+ * @param {Boolean} yoyo
261
+ */
262
+ yoyo( yoyo ) {
263
+
264
+ this._yoyo = yoyo;
265
+ return this;
350
266
 
351
- };
267
+ }
352
268
 
353
- /**
354
- * onComplete callback
355
- * @name me.Tween#onComplete
356
- * @public
357
- * @function
358
- * @param {Function} onCompleteCallback callback
359
- */
360
- this.onComplete = function ( callback ) {
269
+ /**
270
+ * set the easing function
271
+ * @name easing
272
+ * @memberOf me.Tween
273
+ * @public
274
+ * @function
275
+ * @param {me.Tween.Easing} fn easing function
276
+ */
277
+ easing( easing ) {
278
+ if (typeof easing !== "function") {
279
+ throw new Error("invalid easing function for me.Tween.easing()");
280
+ }
281
+ this._easingFunction = easing;
282
+ return this;
361
283
 
362
- _onCompleteCallback = callback;
363
- return this;
284
+ }
364
285
 
365
- };
286
+ /**
287
+ * set the interpolation function
288
+ * @name interpolation
289
+ * @memberOf me.Tween
290
+ * @public
291
+ * @function
292
+ * @param {me.Tween.Interpolation} fn interpolation function
293
+ */
294
+ interpolation( interpolation ) {
295
+ this._interpolationFunction = interpolation;
296
+ return this;
297
+ }
366
298
 
367
- /** @ignore */
368
- this.update = function ( dt ) {
299
+ /**
300
+ * chain the tween
301
+ * @name chain
302
+ * @memberOf me.Tween
303
+ * @public
304
+ * @function
305
+ * @param {me.Tween} chainedTween Tween to be chained
306
+ */
307
+ chain() {
308
+ this._chainedTweens = arguments;
309
+ return this;
310
+ }
369
311
 
370
- // the original Tween implementation expect
371
- // a timestamp and not a time delta
372
- _tweenTimeTracker = (timer.lastUpdate > _tweenTimeTracker) ? timer.lastUpdate : _tweenTimeTracker + dt;
373
- var time = _tweenTimeTracker;
312
+ /**
313
+ * onStart callback
314
+ * @name onStart
315
+ * @memberOf me.Tween
316
+ * @public
317
+ * @function
318
+ * @param {Function} onStartCallback callback
319
+ */
320
+ onStart( callback ) {
321
+ this._onStartCallback = callback;
322
+ return this;
323
+ }
374
324
 
375
- var property;
325
+ /**
326
+ * onUpdate callback
327
+ * @name onUpdate
328
+ * @memberOf me.Tween
329
+ * @public
330
+ * @function
331
+ * @param {Function} onUpdateCallback callback
332
+ */
333
+ onUpdate( callback ) {
334
+ this._onUpdateCallback = callback;
335
+ return this;
336
+ }
376
337
 
377
- if ( time < _startTime ) {
338
+ /**
339
+ * onComplete callback
340
+ * @name onComplete
341
+ * @memberOf me.Tween
342
+ * @public
343
+ * @function
344
+ * @param {Function} onCompleteCallback callback
345
+ */
346
+ onComplete( callback ) {
347
+ this._onCompleteCallback = callback;
348
+ return this;
349
+ };
378
350
 
379
- return true;
351
+ /** @ignore */
352
+ update( dt ) {
380
353
 
381
- }
354
+ // the original Tween implementation expect
355
+ // a timestamp and not a time delta
356
+ this._tweenTimeTracker = (lastUpdate > this._tweenTimeTracker) ? lastUpdate : this._tweenTimeTracker + dt;
357
+ var time = this._tweenTimeTracker;
382
358
 
383
- if ( _onStartCallbackFired === false ) {
359
+ var property;
384
360
 
385
- if ( _onStartCallback !== null ) {
361
+ if ( time < this._startTime ) {
386
362
 
387
- _onStartCallback.call( _object );
363
+ return true;
388
364
 
389
- }
365
+ }
390
366
 
391
- _onStartCallbackFired = true;
367
+ if ( this._onStartCallbackFired === false ) {
368
+
369
+ if ( this._onStartCallback !== null ) {
370
+
371
+ this._onStartCallback.call( this._object );
392
372
 
393
373
  }
394
374
 
395
- var elapsed = ( time - _startTime ) / _duration;
396
- elapsed = elapsed > 1 ? 1 : elapsed;
375
+ this._onStartCallbackFired = true;
397
376
 
398
- var value = _easingFunction( elapsed );
377
+ }
399
378
 
400
- for ( property in _valuesEnd ) {
379
+ var elapsed = ( time - this._startTime ) / this._duration;
380
+ elapsed = elapsed > 1 ? 1 : elapsed;
401
381
 
402
- var start = _valuesStart[ property ] || 0;
403
- var end = _valuesEnd[ property ];
382
+ var value = this._easingFunction( elapsed );
404
383
 
405
- if ( end instanceof Array ) {
384
+ for ( property in this._valuesEnd ) {
406
385
 
407
- _object[ property ] = _interpolationFunction( end, value );
386
+ var start = this._valuesStart[ property ] || 0;
387
+ var end = this._valuesEnd[ property ];
408
388
 
409
- } else {
389
+ if ( end instanceof Array ) {
410
390
 
411
- // Parses relative end values with start as base (e.g.: +10, -3)
412
- if ( typeof(end) === "string" ) {
413
- end = start + parseFloat(end);
414
- }
391
+ this._object[ property ] = this._interpolationFunction( end, value );
415
392
 
416
- // protect against non numeric properties.
417
- if ( typeof(end) === "number" ) {
418
- _object[ property ] = start + ( end - start ) * value;
419
- }
393
+ } else {
420
394
 
395
+ // Parses relative end values with start as base (e.g.: +10, -3)
396
+ if ( typeof(end) === "string" ) {
397
+ end = start + parseFloat(end);
398
+ }
399
+
400
+ // protect against non numeric properties.
401
+ if ( typeof(end) === "number" ) {
402
+ this._object[ property ] = start + ( end - start ) * value;
421
403
  }
422
404
 
423
405
  }
424
406
 
425
- if ( _onUpdateCallback !== null ) {
407
+ }
426
408
 
427
- _onUpdateCallback.call( _object, value );
409
+ if ( this._onUpdateCallback !== null ) {
428
410
 
429
- }
411
+ this._onUpdateCallback.call( this._object, value );
430
412
 
431
- if ( elapsed === 1 ) {
413
+ }
432
414
 
433
- if ( _repeat > 0 ) {
415
+ if ( elapsed === 1 ) {
434
416
 
435
- if( isFinite( _repeat ) ) {
436
- _repeat--;
437
- }
438
-
439
- // reassign starting values, restart by making startTime = now
440
- for( property in _valuesStartRepeat ) {
417
+ if ( this._repeat > 0 ) {
441
418
 
442
- if ( typeof( _valuesEnd[ property ] ) === "string" ) {
443
- _valuesStartRepeat[ property ] = _valuesStartRepeat[ property ] + parseFloat(_valuesEnd[ property ]);
444
- }
419
+ if ( isFinite( this._repeat ) ) {
420
+ this._repeat--;
421
+ }
445
422
 
446
- if (_yoyo) {
447
- var tmp = _valuesStartRepeat[ property ];
448
- _valuesStartRepeat[ property ] = _valuesEnd[ property ];
449
- _valuesEnd[ property ] = tmp;
450
- }
451
- _valuesStart[ property ] = _valuesStartRepeat[ property ];
423
+ // reassign starting values, restart by making startTime = now
424
+ for ( property in this._valuesStartRepeat ) {
452
425
 
426
+ if ( typeof( this._valuesEnd[ property ] ) === "string" ) {
427
+ this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ]);
453
428
  }
454
429
 
455
- if (_yoyo) {
456
- _reversed = !_reversed;
430
+ if (this._yoyo) {
431
+ var tmp = this._valuesStartRepeat[ property ];
432
+ this._valuesStartRepeat[ property ] = this._valuesEnd[ property ];
433
+ this._valuesEnd[ property ] = tmp;
457
434
  }
435
+ this._valuesStart[ property ] = this._valuesStartRepeat[ property ];
458
436
 
459
- _startTime = time + _delayTime;
437
+ }
460
438
 
461
- return true;
439
+ if (this._yoyo) {
440
+ this._reversed = !this._reversed;
441
+ }
462
442
 
463
- } else {
464
- // remove the tween from the world container
465
- game.world.removeChildNow(this);
443
+ this._startTime = time + this._delayTime;
466
444
 
467
- if ( _onCompleteCallback !== null ) {
445
+ return true;
468
446
 
469
- _onCompleteCallback.call( _object );
447
+ } else {
448
+ // remove the tween from the world container
449
+ world.removeChildNow(this);
470
450
 
471
- }
451
+ if ( this._onCompleteCallback !== null ) {
472
452
 
473
- for ( var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i ++ ) {
453
+ this._onCompleteCallback.call( this._object );
474
454
 
475
- _chainedTweens[ i ].start( time );
455
+ }
476
456
 
477
- }
457
+ for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) {
478
458
 
479
- return false;
459
+ this._chainedTweens[ i ].start( time );
480
460
 
481
461
  }
482
462
 
483
- }
463
+ return false;
484
464
 
485
- return true;
465
+ }
486
466
 
487
- };
467
+ }
468
+ return true;
488
469
  }
489
470
 
490
471
  // export easing function as static class property
491
472
  static get Easing() { return Easing; }
492
473
  static get Interpolation() { return Interpolation; }
493
474
  };
494
- /* eslint-enable quotes, keyword-spacing, comma-spacing, no-return-assign */
475
+
495
476
  export default Tween;