A static Tile batch renderer.
TileGroup follows an upload-once policy and does not allow modification of the already added geometry.
To add new geometry it's mandatory to call TileGroup.invalidate
. In case existing geometry has to be modified -
entire group have to be cleared with TileGroup.clear
and repopulated from ground up.
Usage note: While TileGroup allows for multiple unique textures, each texture swap causes a new drawcall, and due to that it's recommended to minimize the amount of used textures per TileGroup instance, ideally limiting to only one texture.
Constructor
new(?t:Tile, ?parent:Object)
Create new TileGroup instance using Texture based on provided Tile.
Parameters:
t | The Tile which is used as a source for a Texture to be rendered. |
---|---|
parent | An optional parent |
Variables
Methods
inlineadd(x:Float, y:Float, t:Tile):Void
Adds a Tile at specified position. Tile is tinted by the current default color.
Parameters:
x | X position of the tile relative to the TileGroup. |
---|---|
y | Y position of the tile relative to the TileGroup. |
t | The Tile to draw. |
inlineaddAlpha(x:Float, y:Float, a:Float, t:Tile):Void
Adds a Tile at specified position. Tile is tinted by the current default color RGB value and provided alpha.
Parameters:
x | X position of the tile relative to the TileGroup. |
---|---|
y | Y position of the tile relative to the TileGroup. |
a | Alpha of the drawn Tile. |
t | The Tile to draw. |
inlineaddColor(x:Float, y:Float, r:Float, g:Float, b:Float, a:Float, t:Tile):Void
Adds a tinted Tile at specified position.
Parameters:
x | X position of the tile relative to the TileGroup. |
---|---|
y | Y position of the tile relative to the TileGroup. |
r | Red tint value (0...1 range). |
g | Green tint value (0...1 range). |
b | Blue tint value (0...1 range). |
a | Alpha of the drawn Tile. |
t | The Tile to draw. |
inlineaddTransform(x:Float, y:Float, sx:Float, sy:Float, r:Float, t:Tile):Void
Adds a Tile at specified position with provided transform. Tile is tinted by the current default color.
Parameters:
x | X position of the tile relative to the TileGroup. |
---|---|
y | Y position of the tile relative to the TileGroup. |
sx | X-axis scaling factor of the Tile. |
sy | Y-axis scaling factor of the Tile. |
r | Rotation (in radians) of the Tile. |
t | The Tile to draw. |
privatedrawWith(ctx:RenderContext, obj:Drawable):Void
Render the TileGroup contents using the referenced Drawable position, shaders and other parameters.
An advanced rendering approach, that allows to render TileGroup contents relative to another object
and used primarily by Text
and HtmlText
.
Parameters:
ctx | The render context with which to render the TileGroup. |
---|---|
obj | The Drawable which will be used as a source of the rendering parameters. |
invalidate():Void
When new data is added, it's not automatically flushed to the GPU memory if it was already allocated
(when TileGroup is either rendered or received Object.sync
call),
in which case call invalidate()
to force a refresh of the GPU data.
setDefaultColor(rgb:Int, alpha:Float = 1.0):Void
Sets the default tinting color when adding new Tiles.