mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-14 11:51:21 +08:00
fix: correctly calculating frame length (#1578)
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user