Skip to content

Commit 2b374c7

Browse files
committed
AnimationState.skipMissedFrames is now used when playing an animation, allowing you to create animations that run at frame rates far exceeding the refresh rate, or that will update to the correct frame should the game lag. Close phaserjs#4232
1 parent ace5b8c commit 2b374c7

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/gameobjects/components/AnimationState.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,8 @@ var AnimationState = new Class({
14711471
}
14721472
else if (this.accumulator >= this.nextTick)
14731473
{
1474+
// Process one frame advance as standard
1475+
14741476
if (this.forward)
14751477
{
14761478
anim.nextFrame(this);
@@ -1479,6 +1481,23 @@ var AnimationState = new Class({
14791481
{
14801482
anim.previousFrame(this);
14811483
}
1484+
1485+
// And only do more if we're skipping frames and have time left
1486+
if (this.skipMissedFrames && this.accumulator > this.nextTick)
1487+
{
1488+
do
1489+
{
1490+
if (this.forward)
1491+
{
1492+
anim.nextFrame(this);
1493+
}
1494+
else
1495+
{
1496+
anim.previousFrame(this);
1497+
}
1498+
1499+
} while (this.accumulator > this.nextTick);
1500+
}
14821501
}
14831502
},
14841503

0 commit comments

Comments
 (0)