Skip to content

Commit

Permalink
Added loopPoint to FlxAnimation (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric authored Aug 16, 2022
1 parent 75a2789 commit b5a91ad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions flixel/animation/FlxAnimation.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class FlxAnimation extends FlxBaseAnimation
*/
public var looped(default, null):Bool = true;

/**
* The custom loop point for this animation.
* This allows you to skip the first few frames of an animation when looping.
*/
public var loopPoint:Int = 0;

/**
* Whether or not this animation is being played backwards.
*/
Expand Down Expand Up @@ -191,15 +197,15 @@ class FlxAnimation extends FlxBaseAnimation
_frameTimer -= delay;
if (reversed)
{
if (looped && curFrame == 0)
if (looped && curFrame == loopPoint)
curFrame = numFrames - 1;
else
curFrame--;
}
else
{
if (looped && curFrame == numFrames - 1)
curFrame = 0;
curFrame = loopPoint;
else
curFrame++;
}
Expand Down

0 comments on commit b5a91ad

Please sign in to comment.