mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
b19449f518
1 changed files with 34 additions and 5 deletions
|
@ -583,8 +583,7 @@ var Animation = new Class({
|
|||
// Yoyo? (happens before repeat)
|
||||
if (component._yoyo)
|
||||
{
|
||||
component.forward = false;
|
||||
this._updateAndGetNextTick(component, frame.prevFrame);
|
||||
this._handleYoyoFrame(component, false);
|
||||
}
|
||||
else if (component.repeatCounter > 0)
|
||||
{
|
||||
|
@ -610,6 +609,37 @@ var Animation = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle the yoyo functionality in nextFrame and previousFrame methods.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#_handleYoyoFrame
|
||||
* @since 3.12.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance.
|
||||
* @param {bool} isReverse - Is animation in reverse mode? (Default: false)
|
||||
*/
|
||||
_handleYoyoFrame: function (component, isReverse)
|
||||
{
|
||||
if (!isReverse) { isReverse = false; }
|
||||
|
||||
if (component._reverse === !isReverse && component.repeatCounter > 0)
|
||||
{
|
||||
component.forward = isReverse;
|
||||
this.repeatAnimation(component);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component._reverse !== isReverse && component.repeatCounter === 0)
|
||||
{
|
||||
this.completeAnimation(component);
|
||||
return;
|
||||
}
|
||||
|
||||
component.forward = isReverse;
|
||||
var frame = isReverse ? component.currentFrame.nextFrame : component.currentFrame.prevFrame;
|
||||
this._updateAndGetNextTick(component, frame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the animation last frame.
|
||||
*
|
||||
|
@ -643,15 +673,14 @@ var Animation = new Class({
|
|||
|
||||
if (component._yoyo)
|
||||
{
|
||||
component.forward = true;
|
||||
this._updateAndGetNextTick(component, frame.nextFrame);
|
||||
this._handleYoyoFrame(component, true);
|
||||
}
|
||||
else if (component.repeatCounter > 0)
|
||||
{
|
||||
if (component._reverse && !component.forward)
|
||||
{
|
||||
component.currentFrame = this.getLastFrame();
|
||||
this._updateAndGetNextTick(component, component.currentFrame);
|
||||
this.repeatAnimation(component);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue