getFrame method
Returns the Rect that defines the boundaries of the frame specified by the index
.
Implementation
@override
Rect getFrame(int index) {
// Given a frame index, return the rect that describes that frame in the image.
if (_image == null) throw ('SpriteSheet.getFrame called before isReady');
if (index < 0) throw ('Bad index passed to SpriteSheet.getFrame');
index = index % length;
int x = index % _cols;
int y = (index / _cols).floor();
return Rect.fromLTWH(
x * _frameWidth,
y * _frameHeight,
_frameWidth,
_frameHeight,
);
}