Issue : Spritesheet, first and last frame last half long

Hi,

Sorry another issue ^^, but i found exactly where the problem is.

In the great spritesheet library used for animation, i found that the animation was weird in the loop animation. It’s because the first and the last frame last half the time of the other frames.

It’s due to the Math.round in the update method of AnimatedSprite, for the first and the last frame you lose half of the elapsedTime.
currentFrameIndex = Math.round (ratio * (currentBehavior.frames.length - 1));

Example with 3 frames:
-1st image will be displayed for ratio between 0 and 0.25
-2nd image will be displayed for ratio between 0.25 and 0.75
-3rd image will be displayed for ratio between 0.75 and 1

I have corrected it on my version with a Math.floor:

		if (ratio >= 1)
			currentFrameIndex  = (currentBehavior.frames.length - 1);
		else
			currentFrameIndex = Math.floor (ratio * currentBehavior.frames.length);
1 Like

Would you like to make a quick pull request with Math.floor? Is this github.com/openfl/spritesheet?

Okay i’ll do it this evening, i have never done this on github.