PICO-8 Wiki
Advertisement
spr( n, [x,] [y,] [w,] [h,] [flip_x,] [flip_y] )
Draws a sprite, or a range of sprites, on the screen.
n
The sprite number. When drawing a range of sprites, this is the upper-left corner.

x
The x coordinate (pixels). The default is 0.

y
The y coordinate (pixels). The default is 0.

w
The width of the range, as a number of sprites. Non-integer values may be used to draw partial sprites. Requires h to be supplied as well. The default is 1.0.

h
The height of the range, as a number of sprites. Non-integer values may be used to draw partial sprites. Required if w is supplied. The default is 1.0.

flip_x
If true, the sprite is drawn inverted left to right. The default is false.

flip_y
If true, the sprite is drawn inverted top to bottom. The default is false.

This operation is affected by the draw state.

Examples[]

-- draw sprite 1 (1x1) at (60, 60) 
spr(1, 60, 60)

-- draw sprite 1 (1x1) at (72, 60), flipped vertically
spr(1, 72, 60, 1, 1, false, true)

-- draw the top-left quarter of sprite 1 at (72, 60)
spr(1, 72, 60, 0.5, 0.5)

-- draw sprite range starting at sprite 16, 3 wide 2 high, at (20, 52)
spr(16, 20, 52, 3, 2)
The spr function in action.
The sprite sheet used in this example.

See also[]

Advertisement