SPR
spr
= "sprite"
spr( sprite_number, x, y, [w, h], [flip_x], [flip_y] )
sprite_number | the sprite number |
x | how far from the left of the screen to draw the sprite. |
y | how far from the top of the screen to draw the sprite. |
w | (optional) how many tiles wide to draw from the sprite sheet. (default 1) |
h | (optional) how many tiles tall to draw from the sprite sheet. (default 1) |
flip_x | (optional) boolean, if true draw the sprite flipped horizontally. (default false) |
flip_y | (optional) boolean, if true draw the sprite flipped vertically. (default false) |
This function will draw a sprite from the sprite sheet to the screen. You must provide the (x,y) position of where to draw the sprite. The pixel at the screen position (x,y) will be the top left pixel of the sprite. When flipping the sprite, this screen position is not changed, only how the sprite is drawn at this same position.
You may optionally provide w (width) and h (height) arguments to draw sprites larger than a single 8x8 pixel tile. Note that width and height arguments are given as tiles, not pixels, so a width of 2 and height of 3 will draw a 16x24 pixel sprite.
You may optionally provide flip arguments. Note that you must provide width and height arguments before these flip arguments, even if you want the default width and height.
spr( 1, 10,20, true ) --will not draw
spr( 1, 10,20, 1,1, true ) --will draw flipped
Example:
-- 16x16 sprite
spr( 1, 10, 20, 2, 2 )
2221
29 Apr 2024