Constructor

Properties

read only alpha :AnimatedFloat

The alpha (opacity) of this sprite, between 0 (invisible) and 1 (fully opaque).

read only anchorX :AnimatedFloat

The X position of this sprite's anchor point. Local transformations are applied relative to this point.

read only anchorY :AnimatedFloat

The Y position of this sprite's anchor point. Local transformations are applied relative to this point.

blendMode :BlendMode

The blend mode used to draw this sprite, or null to use its parent's blend mode.

pixelSnapping :Bool

Whether this sprite's position will be rounded to the nearest whole pixel when rendering, for crisper images. Defaults to true. This can be disabled for smoother animation, at the risk of fuzziness when an image lies on a subpixel.

read only pointerDown :Signal1<PointerEvent>

Emitted when the pointer is pressed down over this sprite.

pointerEnabled :Bool

Whether this sprite or any children should receive pointer events. Defaults to true.

read only pointerIn :Signal1<PointerEvent>

Emitted when the pointer is moved inside of this sprite.

read only pointerMove :Signal1<PointerEvent>

Emitted when the pointer is moved over this sprite.

read only pointerOut :Signal1<PointerEvent>

Emitted when the pointer is moved outside of this sprite. If the pointer is a touch, also emitted when the touch is lifted from this sprite.

read only pointerUp :Signal1<PointerEvent>

Emitted when the pointer is raised over this sprite.

read only rotation :AnimatedFloat

Rotation angle, in degrees.

read only scaleX :AnimatedFloat

Horizontal scale factor.

read only scaleY :AnimatedFloat

Vertical scale factor.

scissor :Rectangle

The scissor rectangle used for clipping/masking, in the local coordinate system. The scissor rectangle affects both rendering and hit testing, and applies to this sprite and all children. Rectangles with negative width or height are OK.

WARNING: When using scissor testing, this sprite (and its parents) must not be rotated. The scissor rectangle must be axis-aligned when converted to screen coordinates.

visible :Bool

Whether this sprite should be drawn. Invisible sprites do not receive pointer events.

read only x :AnimatedFloat

X position, in pixels.

read only y :AnimatedFloat

Y position, in pixels.

Methods

View source

centerAnchor () :Sprite

Chainable convenience method to center the anchor using the natural width and height.

Returns:

This instance, for chaining.

View source

contains (viewX :Float, viewY :Float) :Bool

Returns true if the given point (in viewport/stage coordinates) lies inside this sprite.

View source

containsLocal (localX :Float, localY :Float) :Bool

Returns true if the given point (in local coordinates) lies inside this sprite.

View source

disablePixelSnapping () :Sprite

Chainable convenience method to set pixelSnapping to false.

Returns:

This instance, for chaining.

View source

disablePointer () :Sprite

Chainable convenience method to set pointerEnabled to false.

Returns:

This instance, for chaining.

View source

draw (g :Graphics) :Void

Draws this sprite to the given Graphics.

View source

getLocalMatrix () :Matrix

Returns the local transformation matrix, relative to the parent. This matrix may be modified to position the sprite, but any changes will be invalidated when the x, y, scaleX, scaleY, rotation, anchorX, or anchorY properties are updated.

View source

getNaturalHeight () :Float

The "natural" height of this sprite, without any transformations being applied. Used for hit testing. This does not consider child sprites, use Sprite.getBounds for that.

View source

getNaturalWidth () :Float

The "natural" width of this sprite, without any transformations being applied. Used for hit testing. This does not consider child sprites, use Sprite.getBounds for that.

View source

getViewMatrix () :Matrix

Returns the view transformation matrix, relative to the root. Do NOT modify this matrix.

View source

setAlpha (alpha :Float) :Sprite

Chainable convenience method to set the alpha.

Returns:

This instance, for chaining.

View source

setAnchor (x :Float, y :Float) :Sprite

Chainable convenience method to set the anchor position.

Returns:

This instance, for chaining.

View source

setBlendMode (blendMode :BlendMode) :Sprite

Chainable convenience method to set the blendMode.

Returns:

This instance, for chaining.

View source

setRotation (rotation :Float) :Sprite

Chainable convenience method to set the rotation.

Returns:

This instance, for chaining.

View source

setScale (scale :Float) :Sprite

Chainable convenience method to uniformly set the scale.

Returns:

This instance, for chaining.

View source

setScaleXY (scaleX :Float, scaleY :Float) :Sprite

Chainable convenience method to set the scale.

Returns:

This instance, for chaining.

View source

setXY (x :Float, y :Float) :Sprite

Chainable convenience method to set the position.

Returns:

This instance, for chaining.

Static properties

View source

static read only NAME :String

Static methods

View source

static getBounds (entity :Entity, ?result :Rectangle) :Rectangle

Calculate the bounding box of an entity hierarchy. Returns the smallest rectangle in local coordinates that fully encloses all child sprites.

View source

static hitTest (entity :Entity, x :Float, y :Float) :Sprite

Search for a sprite in the entity hierarchy lying under the given point, in local coordinates. Ignores sprites that are invisible or not pointerEnabled during traversal. Returns null if neither the entity or its children contain a sprite under the given point.

View source

static render (entity :Entity, g :Graphics) :Void

Renders an entity hierarchy to the given Graphics.