No edit summary Tags: Visual edit apiedit |
m (→See also: formatting) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{ApiReference |
||
− | '''spr(n, x, y, [w, h], [flip_x], [flip_y])''' |
||
+ | |name=spr |
||
− | |||
− | Draws a sprite, or a range of sprites, on the screen. |
+ | |shortdesc=Draws a sprite, or a range of sprites, on the screen. |
⚫ | |||
− | |||
+ | |x||The x coordinate. |
||
⚫ | |||
− | + | |y||The y coordinate. |
|
− | + | |w|optional|The width of the range, as a number of sprites. Non-integer values may be used to draw partial sprites. The default is 1.0. |
|
+ | |h|optional|The height of the range, as a number of sprites. Non-integer values may be used to draw partial sprites. The default is 1.0. |
||
⚫ | |||
− | + | |flip_x|optional|If <code>true</code>, the sprite is drawn inverted left to right. The default is <code>false</code>. |
|
⚫ | |||
− | |||
+ | }} |
||
− | This |
+ | This operation is affected by the [[DrawState|draw state]]. |
== Examples == |
== Examples == |
||
+ | <syntaxhighlight lang="lua"> |
||
− | <pre> |
||
-- draw sprite 1 (1x1) at (60, 60) |
-- draw sprite 1 (1x1) at (60, 60) |
||
spr(1, 60, 60) |
spr(1, 60, 60) |
||
Line 18: | Line 19: | ||
-- draw sprite 1 (1x1) at (72, 60), flipped vertically |
-- draw sprite 1 (1x1) at (72, 60), flipped vertically |
||
spr(1, 72, 60, 1, 1, false, true) |
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) |
-- draw sprite range starting at sprite 16, 3 wide 2 high, at (20, 52) |
||
spr(16, 20, 52, 3, 2) |
spr(16, 20, 52, 3, 2) |
||
+ | </syntaxhighlight> |
||
− | </pre> |
||
− | [[File:Spr ex1.png|thumb|220x220px]] |
+ | [[File:Spr ex1.png|thumb|center|220x220px|alt=The spr function in action.]] |
− | [[File:Spr ex1 sprites.png|thumb|216x216px]] |
+ | [[File:Spr ex1 sprites.png|thumb|center|216x216px|alt=The sprite sheet used in this example.]] |
== See also == |
== See also == |
||
* [[Graphics]] |
* [[Graphics]] |
||
− | * [[ |
+ | * [[DrawState|Draw state]] |
+ | * [[Sspr|<code>sspr()</code>]] |
||
− | * [[pal]] |
||
− | * [[ |
+ | * [[Pal|<code>pal()</code>]] |
+ | * [[Palt|<code>palt()</code>]] |
||
[[Category:Reference]] |
[[Category:Reference]] |
||
+ | [[Category:API]] |
Revision as of 13:38, 15 June 2018
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. Non-integer values may be used to draw partial sprites. 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. The default is 1.0.
- flip_x
-
- If
true
, the sprite is drawn inverted left to right. The default isfalse
.
- If
- flip_y
-
- If
true
, the sprite is drawn inverted top to bottom. The default isfalse
.
- If
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)