mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Added 'playReverse' method, and extracted part of play method (issue #3837)
This commit is contained in:
parent
ebc9d8d96d
commit
bb17c82bf9
1 changed files with 45 additions and 2 deletions
|
@ -496,6 +496,50 @@ var Animation = new Class({
|
|||
return this.parent;
|
||||
}
|
||||
|
||||
this.forward = true;
|
||||
return this._startAnimation(key, startFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#playReverse
|
||||
* @fires Phaser.GameObjects.Components.Animation#onStartEvent
|
||||
*
|
||||
* @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager.
|
||||
* @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call.
|
||||
* @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
playReverse: function (key, ignoreIfPlaying, startFrame)
|
||||
{
|
||||
if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; }
|
||||
if (startFrame === undefined) { startFrame = 0; }
|
||||
|
||||
if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key)
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
this.forward = false;
|
||||
return this._startAnimation(key, startFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Load an Animation and fires 'onStartEvent' event,
|
||||
* extracted from 'play' method
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#_startAnimation
|
||||
* @fires Phaser.GameObjects.Components.Animation#onStartEvent
|
||||
*
|
||||
* @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager.
|
||||
* @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
_startAnimation: function (key, startFrame)
|
||||
{
|
||||
this.load(key, startFrame);
|
||||
|
||||
var anim = this.currentAnim;
|
||||
|
@ -505,8 +549,7 @@ var Animation = new Class({
|
|||
this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat;
|
||||
|
||||
anim.getFirstTick(this);
|
||||
|
||||
this.forward = true;
|
||||
|
||||
this.isPlaying = true;
|
||||
this.pendingRepeat = false;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue