Keyframe class

A Keyframe represents a rect on a spritesheet.

The rect can also have a relative origin which should offset the final image at the time of draw. flipX flips the sprite horizontally when true. flipY flips the sprite vertically when true. isEmpty represents an invisible Keyframe with no rect data. duration is how many frames the rect should last in Frametime.

flippedRect is the rect after flipX and flipY transformations. flippedRect is the origin after flipX and flipY transformations.

Keyframes support scene-graph based renderers with child nodes. Therefore, arbitrary points with a name stored in LabeledPoint.label can be used to attach child nodes at specific locations relative to this frame.

See Keyframe.pointOffset to return a calculated Point with encoded offset with respect to Keyframe.origin of a matching LabeledPoint.

Constructors

Keyframe({required KeyframeRect rect, required Point<int> origin, required Frametime duration, bool flipX = false, bool flipY = false})
Construct a rectangular keyframe rect with a duration and origin.
Keyframe.empty({required Frametime duration})
Construct an empty, invisible, shapeless keyframe with a duration.

Properties

attrs List<Attribute>
List of user-defined Attribute elements tagged to this Keyframe.
getter/setter pair
duration Frametime
The duration of this Keyframe in Frametime.
getter/setter pair
flippedOrigin Point<int>
If this Keyframe represents an empty frame e.g. Keyframe.isEmpty, then returns Keyframe._pointZeroInt. Otherwise, return Keyframe.origin with respect to Keyframe.flipX and Keyframe.flipY.
no setter
flippedRect KeyframeRect
If this Keyframe represents an empty frame e.g. Keyframe.isEmpty, then returns Keyframe._rectZero. Otherwise, return KeyframeRect with respect to Keyframe.flipX and Keyframe.flipY.
no setter
flipX bool
Whether or not this frame is flipped horizontally.
getter/setter pair
flipY bool
Whether or not this frame is flipped vertically.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether or not this Keyframe represents a blank frame. This is useful for flickering effects or hiding a sprite.
final
origin Point<int>
Represents the local point (0,0) on the source texture.
getter/setter pair
points Map<String, LabeledPoint>
A map of String names to LabeledPoint points.
getter/setter pair
rect KeyframeRect
Represents the position on the texture (x,y) where this Keyframe begins. Combined with a width and height, represents the visible cell of the sprite at some moment.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canonicalOrigin({bool considerFlip = false}) Point<double>
If considerFlip is true, this method uses flippedOrigin and flippedRect for calculating the canonical origin values. Default value is false.
flippedPoint(Point<int> point) Point<int>
Given a point, returns a new Point with respect to Keyframe.flipX and Keyframe.flipY.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pointOffset({required String point, bool considerFlip = false}) Point<int>?
If the name point matches a LabeledPoint in this Keyframe, then return the calculated offset encoded in Point with respect to Keyframe.origin. If no point is found, returns null.
toString() String
A string representation of this object.
override

Operators

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