Skip to content

Commit b0872c1

Browse files
committed
The Component.Animation.updateFrame method has now been removed. Everything is handled by setCurrentFrame instead, which removes one extra step out of the update process.
1 parent af0f207 commit b0872c1

2 files changed

Lines changed: 21 additions & 36 deletions

File tree

src/animations/Animation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ var Animation = new Class({
662662
*/
663663
updateAndGetNextTick: function (component, frame)
664664
{
665-
component.updateFrame(frame);
665+
component.setCurrentFrame(frame);
666666

667667
this.getNextTick(component);
668668
},
@@ -748,11 +748,11 @@ var Animation = new Class({
748748

749749
if (component.forward)
750750
{
751-
component.updateFrame(component.currentFrame.nextFrame);
751+
component.setCurrentFrame(component.currentFrame.nextFrame);
752752
}
753753
else
754754
{
755-
component.updateFrame(component.currentFrame.prevFrame);
755+
component.setCurrentFrame(component.currentFrame.prevFrame);
756756
}
757757

758758
if (component.isPlaying)

src/gameobjects/components/Animation.js

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ var Animation = new Class({
607607

608608
if (atFrame !== undefined)
609609
{
610-
this.updateFrame(atFrame);
610+
this.setCurrentFrame(atFrame);
611611
}
612612

613613
return this.parent;
@@ -634,7 +634,7 @@ var Animation = new Class({
634634

635635
if (fromFrame !== undefined)
636636
{
637-
this.updateFrame(fromFrame);
637+
this.setCurrentFrame(fromFrame);
638638
}
639639

640640
return this.parent;
@@ -974,7 +974,7 @@ var Animation = new Class({
974974
this.parent.setVisible(true);
975975
}
976976

977-
this.updateFrame(this.currentFrame);
977+
this.setCurrentFrame(this.currentFrame);
978978

979979
this.hasStarted = true;
980980

@@ -1231,8 +1231,7 @@ var Animation = new Class({
12311231
this._pendingStopValue = 0;
12321232
this._paused = false;
12331233

1234-
// Set frame
1235-
this.updateFrame(anim.frames[0]);
1234+
this.setCurrentFrame(anim.frames[0]);
12361235

12371236
return this.parent;
12381237
},
@@ -1482,9 +1481,15 @@ var Animation = new Class({
14821481
* and applies it to the parent Game Object, adjusting size and origin as needed.
14831482
*
14841483
* @method Phaser.GameObjects.Components.Animation#setCurrentFrame
1484+
* @fires Phaser.Animations.Events#ANIMATION_UPDATE
1485+
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_UPDATE
1486+
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_UPDATE
1487+
* @fires Phaser.Animations.Events#ANIMATION_STOP
1488+
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_STOP
1489+
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_STOP
14851490
* @since 3.4.0
14861491
*
1487-
* @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current.
1492+
* @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to.
14881493
*
14891494
* @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to.
14901495
*/
@@ -1502,6 +1507,11 @@ var Animation = new Class({
15021507
gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY);
15031508
}
15041509

1510+
if (animationFrame.setAlpha)
1511+
{
1512+
gameObject.alpha = animationFrame.alpha;
1513+
}
1514+
15051515
gameObject.setSizeToFrame();
15061516

15071517
if (gameObject._originComponent)
@@ -1516,42 +1526,17 @@ var Animation = new Class({
15161526
}
15171527
}
15181528

1519-
return gameObject;
1520-
},
1521-
1522-
/**
1523-
* Internal frame change handler.
1524-
*
1525-
* @method Phaser.GameObjects.Components.Animation#updateFrame
1526-
* @fires Phaser.Animations.Events#ANIMATION_UPDATE
1527-
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_UPDATE
1528-
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_UPDATE
1529-
* @fires Phaser.Animations.Events#ANIMATION_STOP
1530-
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_STOP
1531-
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_STOP
1532-
* @private
1533-
* @since 3.0.0
1534-
*
1535-
* @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to.
1536-
*/
1537-
updateFrame: function (animationFrame)
1538-
{
1539-
var gameObject = this.setCurrentFrame(animationFrame);
1540-
15411529
if (this.isPlaying)
15421530
{
1543-
if (animationFrame.setAlpha)
1544-
{
1545-
gameObject.alpha = animationFrame.alpha;
1546-
}
1547-
15481531
this.emitEvents(Events.ANIMATION_UPDATE, Events.SPRITE_ANIMATION_KEY_UPDATE, Events.SPRITE_ANIMATION_UPDATE);
15491532

15501533
if (this._pendingStop === 3 && this._pendingStopValue === animationFrame)
15511534
{
15521535
this.stop();
15531536
}
15541537
}
1538+
1539+
return gameObject;
15551540
},
15561541

15571542
/**

0 commit comments

Comments
 (0)