@@ -16,6 +16,13 @@ module Phaser {
1616
1717 export class AnimationManager {
1818
19+ /**
20+ * AnimationManager constructor
21+ *
22+ * Create a new <code>AnimationManager</code>.
23+ *
24+ * @param parent Owner sprite of this manager.
25+ */
1926 constructor ( game : Game , parent : Sprite ) {
2027
2128 this . _game = game ;
@@ -24,16 +31,43 @@ module Phaser {
2431
2532 }
2633
34+ /**
35+ * Local private reference to game.
36+ */
2737 private _game : Game ;
38+ /**
39+ * Local private reference to its owner sprite.
40+ */
2841 private _parent : Sprite ;
2942
43+ /**
44+ * Animation key-value container.
45+ */
3046 private _anims : { } ;
47+ /**
48+ * Index of current frame.
49+ * @type {number }
50+ */
3151 private _frameIndex : number ;
52+ /**
53+ * Data contains animation frames.
54+ * @type {FrameData }
55+ */
3256 private _frameData : FrameData = null ;
3357
58+ /**
59+ * Keeps track of the current animation being played.
60+ */
3461 public currentAnim : Animation ;
62+ /**
63+ * Keeps track of the current frame of animation.
64+ */
3565 public currentFrame : Frame = null ;
3666
67+ /**
68+ * Load animation frame data.
69+ * @param frameData Data to be loaded.
70+ */
3771 public loadFrameData ( frameData : FrameData ) {
3872
3973 this . _frameData = frameData ;
@@ -42,6 +76,14 @@ module Phaser {
4276
4377 }
4478
79+ /**
80+ * Add a new animation.
81+ * @param name What this animation should be called (e.g. "run").
82+ * @param frames An array of numbers/strings indicating what frames to play in what order (e.g. [1, 2, 3] or ['run0', 'run1', run2]).
83+ * @param frameRate The speed in frames per second that the animation should play at (e.g. 60 fps).
84+ * @param loop Whether or not the animation is looped or just plays once.
85+ * @param useNumericIndex Use number indexes instead of string indexes?
86+ */
4587 public add ( name : string , frames : any [ ] = null , frameRate : number = 60 , loop : bool = false , useNumericIndex : bool = true ) {
4688
4789 if ( this . _frameData == null )
@@ -98,6 +140,12 @@ module Phaser {
98140
99141 }
100142
143+ /**
144+ * Play animation with specific name.
145+ * @param name The string name of the animation you want to play.
146+ * @param frameRate FrameRate you want to specify instead of using default.
147+ * @param loop Whether or not the animation is looped or just plays once.
148+ */
101149 public play ( name : string , frameRate ?: number = null , loop ?: bool ) {
102150
103151 if ( this . _anims [ name ] )
@@ -118,6 +166,10 @@ module Phaser {
118166
119167 }
120168
169+ /**
170+ * Stop animation by name.
171+ * Current animation will be automatically set to the stopped one.
172+ */
121173 public stop ( name : string ) {
122174
123175 if ( this . _anims [ name ] )
@@ -128,6 +180,9 @@ module Phaser {
128180
129181 }
130182
183+ /**
184+ * Update animation and parent sprite's bounds.
185+ */
131186 public update ( ) {
132187
133188 if ( this . currentAnim && this . currentAnim . update ( ) == true )
0 commit comments