A base class for SpriteBatch elements which can be extended with custom logic.

See BasicElement as an example of custom element logic.

Constructor

new(t:Tile)

Create a new BatchElement instance with provided Tile.

Parameters:

t

The tile used to render this BatchElement.

Variables

@:value(1)a:Float = 1

Alpha value of the element.

alpha:Float

Alpha value of the element. Alias of BatchElement.a.

@:value(1)b:Float = 1

Blue tint value (0...1 range) of the element.

read onlybatch:SpriteBatch

Reference to parent SpriteBatch instance.

@:value(1)g:Float = 1

Green tint value (0...1 range) of the element.

@:value(1)r:Float = 1

Red tint value (0...1 range) of the element.

@:value(0)rotation:Float = 0

Element rotation in radians.

This variable is used only if SpriteBatch.hasRotationScale is set to true.

write onlyscale:Float

Shortcut to set both BatchElement.scaleX and BatchElement.scaleY at the same time.

Equivalent to el.scaleX = el.scaleY = scale.

@:value(1)scaleX:Float = 1

X-axis scaling factor of the element.

This variable is used only if SpriteBatch.hasRotationScale is set to true.

@:value(1)scaleY:Float = 1

Y-axis scaling factor of the element.

This variable is used only if SpriteBatch.hasRotationScale is set to true.

t:Tile

The Tile this element renders.

Due to implementation specifics, this Tile instance is used only to provide rendering area, not the Texture itself, as SpriteBatch.tile used as a source of rendered texture.

@:value(true)visible:Bool = true

If set to false, element will not be rendered.

@:value(0)x:Float = 0

Element X position.

@:value(0)y:Float = 0

Element Y position.

Methods

remove():Void

Remove this BatchElement from the parent SpriteBatch instance.

private@:dox(show)update(et:Float):Bool

Override this method to perform custom logic per batch element. Update method called only if SpriteBatch.hasUpdate is set to true.

Parameters:

dt

The elapsed time in seconds since last update from RenderContext.elapsedTime.

Returns:

If method returns false, element will be removed from the SpriteBatch.