Fandom

Pico-8 Wiki

Spr

162pages on
this wiki
Add New Page
Comments0 Share
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.
y
The y coordinate.
w
The width of the range, as a number of sprites. The default is 1.
h
The height of the range, as a number of sprites. The default is 1.
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 Edit

-- 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 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 Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.