Sprite class
A Sprite is a region of an Image that can be rendered in the Canvas.
It might represent the entire image or be one of the pieces a spritesheet is
composed of. It holds a reference to the source image from which the region
is extracted, and the src rectangle is the portion inside that image that
is to be rendered (not to be confused with the dest
rect, which is where
in the Canvas the sprite is rendered).
It also has a paint field that can be overwritten to apply a tint to this
Sprite (default is white, meaning no tint).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- image ↔ Image
-
getter/setter pair
- originalSize → Vector2
-
no setter
- paint ↔ Paint
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- src ↔ Rect
-
getter/setter pair
- srcPosition ↔ Vector2
-
getter/setter pair
- srcSize ↔ Vector2
-
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Canvas canvas, {Vector2? position, Vector2? size, Anchor anchor = Anchor.topLeft, Paint? overridePaint}) → void -
Renders this sprite onto the
canvas
. -
renderRect(
Canvas canvas, Rect rect, {Paint? overridePaint}) → void - Same as render, but takes both the position and the size as a single Rect.
-
toImage(
) → Future< Image> - Return a new Image based on the src of the Sprite.
-
toImageSync(
) → Image - Return a new Image based on the src of the Sprite.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited