mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
Adding assertions
This commit is contained in:
@ -22,27 +22,31 @@ class SpriteSheet {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite getSprite(int row, int column) => _sprites[row][column];
|
Sprite getSprite(int row, int column) {
|
||||||
|
final Sprite s = _sprites[row][column];
|
||||||
|
|
||||||
|
assert(s != null, 'No sprite found for row $row and column $column');
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates an animation from this SpriteSheet
|
/// Creates an animation from this SpriteSheet
|
||||||
///
|
///
|
||||||
/// An [from] and a [to] parameter can be specified to create an animation from a subset of the columns on the row
|
/// An [from] and a [to] parameter can be specified to create an animation from a subset of the columns on the row
|
||||||
Animation createAnimation(int row, { double stepTime, loop = true, int from = 0, int to }) {
|
Animation createAnimation(int row, { double stepTime, loop = true, int from = 0, int to }) {
|
||||||
List<Sprite> spriteRow = _sprites[row];
|
final spriteRow = _sprites[row];
|
||||||
|
|
||||||
if (spriteRow != null) {
|
assert(spriteRow != null, 'There is no row for $row index');
|
||||||
to ??= spriteRow.length;
|
|
||||||
|
|
||||||
final spriteList = spriteRow.sublist(from, to);
|
to ??= spriteRow.length;
|
||||||
|
|
||||||
return Animation.spriteList(
|
final spriteList = spriteRow.sublist(from, to);
|
||||||
|
|
||||||
|
return Animation.spriteList(
|
||||||
spriteList,
|
spriteList,
|
||||||
stepTime: stepTime,
|
stepTime: stepTime,
|
||||||
loop: loop,
|
loop: loop,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user