77var Clamp = require ( '../math/Clamp' ) ;
88var Class = require ( '../utils/Class' ) ;
99var EventEmitter = require ( 'eventemitter3' ) ;
10+ var Events = require ( './events' ) ;
1011var FindClosestInSorted = require ( '../utils/array/FindClosestInSorted' ) ;
1112var Frame = require ( './AnimationFrame' ) ;
1213var GetValue = require ( '../utils/object/GetValue' ) ;
1314
14- /**
15- * @typedef {object } JSONAnimation
16- *
17- * @property {string } key - The key that the animation will be associated with. i.e. sprite.animations.play(key)
18- * @property {string } type - A frame based animation (as opposed to a bone based animation)
19- * @property {JSONAnimationFrame[] } frames - [description]
20- * @property {integer } frameRate - The frame rate of playback in frames per second (default 24 if duration is null)
21- * @property {integer } duration - How long the animation should play for in milliseconds. If not given its derived from frameRate.
22- * @property {boolean } skipMissedFrames - Skip frames if the time lags, or always advanced anyway?
23- * @property {integer } delay - Delay before starting playback. Value given in milliseconds.
24- * @property {integer } repeat - Number of times to repeat the animation (-1 for infinity)
25- * @property {integer } repeatDelay - Delay before the animation repeats. Value given in milliseconds.
26- * @property {boolean } yoyo - Should the animation yoyo? (reverse back down to the start) before repeating?
27- * @property {boolean } showOnStart - Should sprite.visible = true when the animation starts to play?
28- * @property {boolean } hideOnComplete - Should sprite.visible = false when the animation finishes?
29- */
30-
31- /**
32- * @typedef {object } AnimationFrameConfig
33- *
34- * @property {string } key - The key that the animation will be associated with. i.e. sprite.animations.play(key)
35- * @property {(string|number) } frame - [description]
36- * @property {number } [duration=0] - [description]
37- * @property {boolean } [visible] - [description]
38- */
39-
40- /**
41- * @typedef {object } AnimationConfig
42- *
43- * @property {string } [key] - The key that the animation will be associated with. i.e. sprite.animations.play(key)
44- * @property {AnimationFrameConfig[] } [frames] - An object containing data used to generate the frames for the animation
45- * @property {string } [defaultTextureKey=null] - The key of the texture all frames of the animation will use. Can be overridden on a per frame basis.
46- * @property {integer } [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null)
47- * @property {integer } [duration] - How long the animation should play for in milliseconds. If not given its derived from frameRate.
48- * @property {boolean } [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway?
49- * @property {integer } [delay=0] - Delay before starting playback. Value given in milliseconds.
50- * @property {integer } [repeat=0] - Number of times to repeat the animation (-1 for infinity)
51- * @property {integer } [repeatDelay=0] - Delay before the animation repeats. Value given in milliseconds.
52- * @property {boolean } [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating?
53- * @property {boolean } [showOnStart=false] - Should sprite.visible = true when the animation starts to play?
54- * @property {boolean } [hideOnComplete=false] - Should sprite.visible = false when the animation finishes?
55- */
56-
5715/**
5816 * @classdesc
5917 * A Frame based Animation.
@@ -72,7 +30,7 @@ var GetValue = require('../utils/object/GetValue');
7230 *
7331 * @param {Phaser.Animations.AnimationManager } manager - [description]
7432 * @param {string } key - [description]
75- * @param {AnimationConfig } config - [description]
33+ * @param {Phaser.Animations.Animation.Config } config - [description]
7634 */
7735var Animation = new Class ( {
7836
@@ -266,7 +224,7 @@ var Animation = new Class({
266224 * @method Phaser.Animations.Animation#addFrame
267225 * @since 3.0.0
268226 *
269- * @param {(string|AnimationFrameConfig []) } config - [description]
227+ * @param {(string|Phaser.Animations.AnimationFrame.Config []) } config - [description]
270228 *
271229 * @return {Phaser.Animations.Animation } This Animation object.
272230 */
@@ -282,7 +240,7 @@ var Animation = new Class({
282240 * @since 3.0.0
283241 *
284242 * @param {integer } index - [description]
285- * @param {(string|AnimationFrameConfig []) } config - [description]
243+ * @param {(string|Phaser.Animations.AnimationFrame.Config []) } config - [description]
286244 *
287245 * @return {Phaser.Animations.Animation } This Animation object.
288246 */
@@ -395,7 +353,7 @@ var Animation = new Class({
395353 * @since 3.0.0
396354 *
397355 * @param {Phaser.Textures.TextureManager } textureManager - [description]
398- * @param {(string|AnimationFrameConfig []) } frames - [description]
356+ * @param {(string|Phaser.Animations.AnimationFrame.Config []) } frames - [description]
399357 * @param {string } [defaultTextureKey] - [description]
400358 *
401359 * @return {Phaser.Animations.AnimationFrame[] } [description]
@@ -774,6 +732,9 @@ var Animation = new Class({
774732 * [description]
775733 *
776734 * @method Phaser.Animations.Animation#repeatAnimation
735+ * @fires Phaser.Animations.Events#ANIMATION_REPEAT
736+ * @fires Phaser.Animations.Events#SPRITE_ANIMATION_REPEAT
737+ * @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT
777738 * @since 3.0.0
778739 *
779740 * @param {Phaser.GameObjects.Components.Animation } component - [description]
@@ -806,11 +767,11 @@ var Animation = new Class({
806767 var frame = component . currentFrame ;
807768 var parent = component . parent ;
808769
809- this . emit ( 'repeat' , this , frame ) ;
770+ this . emit ( Events . ANIMATION_REPEAT , this , frame ) ;
810771
811- parent . emit ( 'animationrepeat-' + this . key , this , frame , component . repeatCounter , parent ) ;
772+ parent . emit ( Events . SPRITE_ANIMATION_KEY_REPEAT + this . key , this , frame , component . repeatCounter , parent ) ;
812773
813- parent . emit ( 'animationrepeat' , this , frame , component . repeatCounter , parent ) ;
774+ parent . emit ( Events . SPRITE_ANIMATION_REPEAT , this , frame , component . repeatCounter , parent ) ;
814775 }
815776 }
816777 } ,
0 commit comments