GPU - spriteBatch
Spritebatch, draw multiple parts of an image at once instantly, useful for maps.
- Available since: GPU: v1.0.0, LIKO-12: v0.9.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.9.0
Methods:
spriteBatch:add
Adds a sprite to the batch.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
id = spriteBatch:add(quad, x, y, r, sx, sy, ox, oy, kx, ky)
Arguments:
- <quad> (GPU/quad): The quad to add.
- [x] (number) (Default:
0
): The x position of the new sprite. - [y] (number) (Default:
0
): The y position of the new sprite. - [r] (number) (Default:
0
): The rotation of the new sprite. - [sx] (number) (Default:
1
): The x scale of the new sprite. - <sy> (number): The y scale of the new sprite.
- [ox] (number) (Default:
0
): The x origin offset of the new sprite. - [oy] (number) (Default:
0
): The y origin offset of the new sprite. - [kx] (number) (Default:
0
): The x shear factor of the new sprite. - [ky] (number) (Default:
0
): The y shear factor of the new sprite.
Returns:
- id (number): The id of the added sprite.
spriteBatch:clear
Clears the sprites from the buffer.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
The function returns the spritebatch object itself, so it can be used for chain calls.
sb = spriteBatch:clear()
Returns:
- sb (GPU/spriteBatch): The spritebatch itself.
spriteBatch:draw
Draws the sprite batch
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
The function returns the spritebatch object itself, so it can be used for chain calls.
sb = spriteBatch:draw(x, y, r, sx, sy, quad)
Arguments:
- [x] (number) (Default:
0
): The x position to draw the sprite batch. - [y] (number) (Default:
0
): The y position to draw the sprite batch. - <r> (number): The rotation to draw the sprite batch with.
- [sx] (number) (Default:
1
): The x scale to draw the sprite batch with. - [sy] (number) (Default:
1
): The y sacle to draw the sprite batch with. - [quad] (GPU/quad) (Default:
nil
): The quad to draw the sprite batch with.
Returns:
- sb (GPU/spriteBatch): The spritebatch itself.
spriteBatch:flush
Immediately refreshes the sprite data.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
The function returns the spritebatch object itself, so it can be used for chain calls.
sb = spriteBatch:flush()
Returns:
- sb (GPU/spriteBatch): The spritebatch itself.
spriteBatch:getBufferSize
Returns the buffer size.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
size = spriteBatch:getBufferSize()
Returns:
- size (number): The size of the buffer.
spriteBatch:getCount
Returns the number of sprites currently in the batch.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
count = spriteBatch:getCount()
Returns:
- count (number): Number of sprites in the batch..
spriteBatch:set
Changes a sprite to the batch.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
The function returns the spritebatch object itself, so it can be used for chain calls.
sb = spriteBatch:set(id, quad, x, y, r, sx, sy, ox, oy, kx, ky)
Arguments:
- <id> (number): The index of the sprite to change.
- <quad> (GPU/quad): The quad to add.
- [x] (number) (Default:
0
): The x position of the new sprite. - [y] (number) (Default:
0
): The y position of the new sprite. - [r] (number) (Default:
0
): The rotation of the new sprite. - [sx] (number) (Default:
1
): The x scale of the new sprite. - <sy> (number): The y scale of the new sprite.
- [ox] (number) (Default:
0
): The x origin offset of the new sprite. - [oy] (number) (Default:
0
): The y origin offset of the new sprite. - [kx] (number) (Default:
0
): The x shear factor of the new sprite. - [ky] (number) (Default:
0
): The y shear factor of the new sprite.
Returns:
- sb (GPU/spriteBatch): The spritebatch itself.
spriteBatch:setBufferSize
Sets the buffer size.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
The function returns the spritebatch object itself, so it can be used for chain calls.
sb = spriteBatch:setBufferSize(size)
Arguments:
- <size> (number): The new buffer size.
Returns:
- sb (GPU/spriteBatch): The spritebatch itself.
spriteBatch:type
Gets the type of the object as a string.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
type = spriteBatch:type()
Returns:
- type (string): The object type, (GPU.spritebatch).
spriteBatch:typeOf
Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
For GPUSprBatch, it returns true for the folowing types: 'GPU', 'spritebatch', 'GPU.spritebatch', 'LK12'
bool = spriteBatch:typeOf(type)
Arguments:
- <type> (string): The name of the type to check for.
Returns:
- bool (boolean): True if the object is of the specified type, false otherwise.
spriteBatch:usage
Returns the batch usage.
- Available since: spriteBatch: v1.0.0, LIKO-12: v0.6.0
- Last updated in: spriteBatch: v1.0.0, LIKO-12: v0.6.0
usage = spriteBatch:usage()
Returns:
- usage (string): The usage of the sprite batch.