Skip to content

Commit

Permalink
fix: correctly calculating frame length (#1578)
Browse files Browse the repository at this point in the history
  • Loading branch information
oloshe authored Apr 26, 2022
1 parent 8e81261 commit efda45e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/flame/lib/src/sprite_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ class SpriteAnimationData {
this.loop = true,
}) : assert(amountPerRow == null || amount >= amountPerRow),
assert(start <= end && start >= 0 && end <= amount),
assert(stepTimes.length == end - start) {
assert(stepTimes.length >= end - start + 1) {
amountPerRow ??= amount;
texturePosition ??= Vector2.zero();
frames = List<SpriteAnimationFrameData>.generate(end - start, (index) {
frames = List<SpriteAnimationFrameData>.generate(end - start + 1, (index) {
final i = index + start;
final position = Vector2(
texturePosition!.x + (i % amountPerRow!) * textureSize.x,
texturePosition.y + (i ~/ amountPerRow) * textureSize.y,
);
return SpriteAnimationFrameData(
stepTime: stepTimes[i],
stepTime: stepTimes[index],
srcPosition: position,
srcSize: textureSize,
);
Expand Down

0 comments on commit efda45e

Please sign in to comment.