@@ -496,6 +496,50 @@ var Animation = new Class({
496496 return this . parent ;
497497 }
498498
499+ this . forward = true ;
500+ return this . _startAnimation ( key , startFrame ) ;
501+ } ,
502+
503+ /**
504+ * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component.
505+ *
506+ * @method Phaser.GameObjects.Components.Animation#playReverse
507+ * @fires Phaser.GameObjects.Components.Animation#onStartEvent
508+ *
509+ * @param {string } key - The string-based key of the animation to play, as defined previously in the Animation Manager.
510+ * @param {boolean } [ignoreIfPlaying=false] - If an animation is already playing then ignore this call.
511+ * @param {integer } [startFrame=0] - Optionally start the animation playing from this frame index.
512+ *
513+ * @return {Phaser.GameObjects.GameObject } The Game Object that owns this Animation Component.
514+ */
515+ playReverse : function ( key , ignoreIfPlaying , startFrame )
516+ {
517+ if ( ignoreIfPlaying === undefined ) { ignoreIfPlaying = false ; }
518+ if ( startFrame === undefined ) { startFrame = 0 ; }
519+
520+ if ( ignoreIfPlaying && this . isPlaying && this . currentAnim . key === key )
521+ {
522+ return this . parent ;
523+ }
524+
525+ this . forward = false ;
526+ return this . _startAnimation ( key , startFrame ) ;
527+ } ,
528+
529+ /**
530+ * Load an Animation and fires 'onStartEvent' event,
531+ * extracted from 'play' method
532+ *
533+ * @method Phaser.GameObjects.Components.Animation#_startAnimation
534+ * @fires Phaser.GameObjects.Components.Animation#onStartEvent
535+ *
536+ * @param {string } key - The string-based key of the animation to play, as defined previously in the Animation Manager.
537+ * @param {integer } [startFrame=0] - Optionally start the animation playing from this frame index.
538+ *
539+ * @return {Phaser.GameObjects.GameObject } The Game Object that owns this Animation Component.
540+ */
541+ _startAnimation : function ( key , startFrame )
542+ {
499543 this . load ( key , startFrame ) ;
500544
501545 var anim = this . currentAnim ;
@@ -505,8 +549,7 @@ var Animation = new Class({
505549 this . repeatCounter = ( this . _repeat === - 1 ) ? Number . MAX_VALUE : this . _repeat ;
506550
507551 anim . getFirstTick ( this ) ;
508-
509- this . forward = true ;
552+
510553 this . isPlaying = true ;
511554 this . pendingRepeat = false ;
512555
0 commit comments