99* @copyright 2013 Photon Storm Ltd.
1010* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
1111*/
12- Phaser . AnimationManager = function ( parent ) {
12+ Phaser . AnimationManager = function ( sprite ) {
1313
1414 /**
1515 * Data contains animation frames.
@@ -22,17 +22,18 @@ Phaser.AnimationManager = function (parent) {
2222 */
2323 this . currentFrame = null ;
2424
25- this . _parent = parent ;
25+ this . sprite = sprite ;
2626
27- this . game = parent . game ;
27+ this . game = sprite . game ;
2828
2929 this . _anims = { } ;
3030
31+ this . updateIfVisible = true ;
32+
3133} ;
3234
3335Phaser . AnimationManager . prototype = {
3436
35- updateIfVisible : true ,
3637
3738 /**
3839 * Load animation frame data.
@@ -68,12 +69,12 @@ Phaser.AnimationManager.prototype = {
6869 }
6970
7071 // Create the signals the AnimationManager will emit
71- // if (this._parent .events.onAnimationStart == null)
72- // {
73- // this._parent .events.onAnimationStart = new Phaser.Signal();
74- // this._parent .events.onAnimationComplete = new Phaser.Signal();
75- // this._parent .events.onAnimationLoop = new Phaser.Signal();
76- // }
72+ if ( this . sprite . events . onAnimationStart == null )
73+ {
74+ this . sprite . events . onAnimationStart = new Phaser . Signal ( ) ;
75+ this . sprite . events . onAnimationComplete = new Phaser . Signal ( ) ;
76+ this . sprite . events . onAnimationLoop = new Phaser . Signal ( ) ;
77+ }
7778
7879 if ( frames == null )
7980 {
@@ -93,10 +94,10 @@ Phaser.AnimationManager.prototype = {
9394 frames = this . _frameData . getFrameIndexesByName ( frames ) ;
9495 }
9596
96- this . _anims [ name ] = new Phaser . Animation ( this . game , this . _parent , this . _frameData , name , frames , frameRate , loop ) ;
97+ this . _anims [ name ] = new Phaser . Animation ( this . game , this . sprite , this . _frameData , name , frames , frameRate , loop ) ;
9798 this . currentAnim = this . _anims [ name ] ;
9899 this . currentFrame = this . currentAnim . currentFrame ;
99- this . _parent . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
100+ this . sprite . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
100101
101102 return this . _anims [ name ] ;
102103
@@ -181,15 +182,15 @@ Phaser.AnimationManager.prototype = {
181182 */
182183 update : function ( ) {
183184
184- if ( this . updateIfVisible && this . _parent . visible == false )
185+ if ( this . updateIfVisible && this . sprite . visible == false )
185186 {
186187 return false ;
187188 }
188189
189190 if ( this . currentAnim && this . currentAnim . update ( ) == true )
190191 {
191192 this . currentFrame = this . currentAnim . currentFrame ;
192- this . _parent . currentFrame = this . currentFrame ;
193+ this . sprite . currentFrame = this . currentFrame ;
193194 return true ;
194195 }
195196
@@ -261,8 +262,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
261262 {
262263 this . currentFrame = this . _frameData . getFrame ( value ) ;
263264 this . _frameIndex = value ;
264- this . _parent . currentFrame = this . currentFrame ;
265- this . _parent . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
265+ this . sprite . currentFrame = this . currentFrame ;
266+ this . sprite . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
266267 }
267268
268269 } ,
@@ -288,8 +289,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
288289 {
289290 this . currentFrame = this . _frameData . getFrameByName ( value ) ;
290291 this . _frameIndex = this . currentFrame . index ;
291- this . _parent . currentFrame = this . currentFrame ;
292- this . _parent . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
292+ this . sprite . currentFrame = this . currentFrame ;
293+ this . sprite . setTexture ( PIXI . TextureCache [ this . currentFrame . uuid ] ) ;
293294 }
294295 else
295296 {
0 commit comments