Skip to main content

Drawing Sprites

For drawing individual sprites and the map into the screen.

Sprite

Draw a single 8x8 sprite into the screen.

Sprite(spriteId, x, y, rotation, scaleX, scaleY, spriteSheet)
ParameterTypeDefaultNote
spriteIdnumber⚠️ requiredThe ID of the sprite shown in the sprite editor.
xnumber0
ynumber0
rotationnumber0in radians.
scaleXnumber11 to preserve scale.
scaleYnumber11 to preserve scale.
spriteSheetSpriteSheetSpriteMap

SpriteGroup

Draw a sprite larger than 8x8 by composing multiple 8x8 sprites together.

SpriteGroup(spriteId, x, y, width, height, scaleX, scaleY, rotation, spriteSheet)
ParameterTypeDefaultNote
spriteIdnumber⚠️ required
xnumber⚠️ required
ynumber⚠️ required
widthnumber⚠️ requiredin sprites (cells).
heightnumber⚠️ requiredin sprites (cells).
scaleXnumber11 to preserve scale.
scaleYnumber11 to preserve scale.
rotationnumber, nilnilin radians. nil saves some performance.
spriteSheetSpriteSheetSpriteMap

map

Draw the game's tile map. (The one edited in the tile map editor).

map(destinationX, destinationY, sourceX, sourceY, sourceWidth, sourceHeight, scaleX, scaleY, spriteSheet)
ParameterTypeDefaultNote
destinationXnumber0in pixels.
destinationYnumber0in pixels.
sourceXnumber0in cells.
sourceYnumber0in cells.
sourceWidthnumbermap widthin cells.
sourceHeightnumbermap heightin cells.
spriteSheetSpriteSheetSpriteMap