spritebatch
spritebatch
¶
Sprite batches: many copies of one texture built up together and drawn in one
go. Add sprites with add, draw the whole thing with draw, and clear to
start over. The current color set with setColor tints sprites added after it.
SpriteBatch
¶
type SpriteBatch = ref object
Many copies of one texture, built up with add and drawn in one call.
Fields
-
textureTexture -
colorColor
Source:
src/nim2d/spritebatch.nim:10
newSpriteBatch ¶
proc newSpriteBatch(image: Texture): SpriteBatch
A sprite batch drawing copies of image.
Parameters
-
image(Texture)
Returns
SpriteBatch
Source:
src/nim2d/spritebatch.nim:17
setColor ¶
proc setColor(batch: SpriteBatch; r, g, b: uint8; a: uint8 = 255)
Tint the sprites added after this call.
Parameters
-
batch(SpriteBatch) -
r(uint8) -
g(uint8) -
b(uint8) -
a(uint8)
Source:
src/nim2d/spritebatch.nim:21
clear ¶
proc clear(batch: SpriteBatch)
Empty the batch to build it up again.
Parameters
-
batch(SpriteBatch)
Source:
src/nim2d/spritebatch.nim:25
count ¶
proc count(batch: SpriteBatch): int
How many sprites the batch holds.
Parameters
-
batch(SpriteBatch)
Returns
int
Source:
src/nim2d/spritebatch.nim:30
add ¶
proc add(batch: SpriteBatch; x, y: float; angle = 0.0; sx = 1.0; sy = 1.0; ox = 0.0; oy = 0.0)
Add one copy of the texture at (x, y), with the same rotation, scale and
origin arguments as drawing an image.
Parameters
-
batch(SpriteBatch) -
x(float) -
y(float) -
angle(auto) -
sx(auto) -
sy(auto) -
ox(auto) -
oy(auto)
Source:
src/nim2d/spritebatch.nim:63
add ¶
proc add(batch: SpriteBatch; quad: Quad; x, y: float; angle = 0.0; sx = 1.0; sy = 1.0; ox = 0.0; oy = 0.0)
Add one copy of just the quad region of the texture, for sprite sheets.
Parameters
-
batch(SpriteBatch) -
quad(Quad) -
x(float) -
y(float) -
angle(auto) -
sx(auto) -
sy(auto) -
ox(auto) -
oy(auto)
Source:
src/nim2d/spritebatch.nim:73
draw ¶
proc draw(batch: SpriteBatch; nim2d: Nim2d; x = 0.0; y = 0.0)
Draw the whole batch in one call, optionally offset by (x, y), through the
current transform.
Parameters
-
batch(SpriteBatch) -
nim2d(Nim2d) -
x(auto) -
y(auto)
Source:
src/nim2d/spritebatch.nim:89
Generated with mkdocstrings-nim