SpriteSheet<T> class

An image cut into a grid of equally sized frames.

Frames are numbered from the start of their row, and a SpriteNode animates along one row. A 128x64 image with a 32x32 size holds two rows of four:

    0              128
  0 +---+---+---+---+
    | 0 | 1 | 2 | 3 |
    +---+---+---+---+
    | 0 | 1 | 2 | 3 |
 64 +---+---+---+---+

A row plays its whole width at the sheet's fps unless a SheetRow says otherwise:

final sheet = SpriteSheet('assets/fire.png', .new(32, 48), fps: 12);
Inheritance

Constructors

SpriteSheet(String asset, Vector2 size, {required num fps, bool? loop, List<SheetRow<T>>? rows})
Cuts the image cached at asset into frames of the given size.
factory
SpriteSheet.single(String asset, Vector2 size, {required num fps, T? key, bool? loop})
Cuts an image that holds one animation, under the name key.
factory

Properties

asset String
The cache key this sheet was cut from.
final
columns int
How many columns of frames the grid holds.
latefinal
fps num
The rate every row without an SheetRow.fps of its own plays at.
final
hashCode int
The hash code for this object.
no setterinherited
loop bool
Whether every row without a SheetRow.loop of its own starts over.
final
rows int
How many rows of frames this holds.
latefinaloverride-getter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

duration(int row, int index) double
How long frame index of row is held, in seconds.
override
frames(int row) int
How many frames row plays.
override
image(int row) Image
The image row is drawn from.
override
loops(int row) bool
Whether row starts over after its last frame.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rect(int row, int index) Rect
Where frame index of row sits in image.
override
reload() SpriteSheet<T>
Re-resolves this sprite against Ignis.cache.
override
rowOf(T key) int?
The row key names, or null where nothing here answers to it.
override
size(int row) Vector2
The size of one frame of row, which a SpriteNode takes as its own.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited