rq.Sprite
since 1.9.0
A mod sprite among the game's own, made by rq.sprite.new.
The methods that return the sprite can be chained.
Functions
| Name | Summary |
|---|---|
rq.Sprite:set | Changes only the options given. |
rq.Sprite:get | Returns the sprite's options now. |
rq.Sprite:remove | Removes the sprite. |
rq.Sprite:alive | Returns whether the sprite is still there. |
rq.Sprite:play | Plays the sprite's GIF or Flash file. |
rq.Sprite:stop | Holds the GIF or the Flash file on the frame it is on. |
rq.Sprite:frame | Returns the frame shown, or shows one and stops. |
rq.Sprite:playing | Returns whether the sprite's GIF or Flash file is playing. |
rq.Sprite:to | Moves the sprite from the values it has now to new ones, over time. |
rq.Sprite:moving | Returns whether a motion is waiting or moving. |
rq.Sprite:halt | Stops the motion where it is, without its on_end. |
rq.Sprite:set
rq.Sprite:set(opts) -> rq.Spritesince 1.9.0
Changes only the options given.
Raises an error for a bad option, or after the sprite was removed.
| Parameter | Type | Description |
|---|---|---|
opts | rq.SpriteOpts | The options to change. |
| Returns | Type | Description |
|---|---|---|
self | rq.Sprite | The sprite. |
rq.Sprite:get
rq.Sprite:get() -> tablesince 1.9.0 changed 1.10.0 changed 1.11.0 changed 2.63.0
Returns the sprite's options now.
Besides the options it has id, mod, w and h before the scale (the content's own size when not set), origin as {x, y}, screen (with keep = "screen"), in_scene (shown and drawn), clock and moving. A GIF sprite adds gif, frame, frames, gif_ms (one time through), fps and playing; a Flash sprite flash, frame, frames, fps, playing and sound. An attached sprite adds attach and drawn = {x, y, z}, where it is drawn now.
Raises an error after the sprite was removed.
| Returns | Type | Description |
|---|---|---|
opts | table | A copy of the options. |
Changed in 1.10.0: Added the GIF and motion fields.
Changed in 1.11.0: Added
attachanddrawn.
Changed in 2.63.0: Added the Flash fields.
rq.Sprite:remove
rq.Sprite:remove()since 1.9.0
Removes the sprite.
set and get raise an error after that.
rq.Sprite:alive
rq.Sprite:alive() -> booleansince 1.9.0
Returns whether the sprite is still there.
| Returns | Type | Description |
|---|---|---|
alive | boolean | false once it was removed: by the mod, a load, the title or keep. |
rq.Sprite:play
rq.Sprite:play(opts) -> rq.Spritesince 1.10.0 changed 2.63.0
Plays the sprite's GIF or Flash file.
A Flash file goes one frame on each 1/30 s, its tags walked in turn as the game walks them: a gotoFrame in it jumps, a stop ends the play as its last frame does, and each sound starts at its frame. Going back to from walks its frames again from the start, without their sounds.
Raises an error for a sprite with no GIF or Flash file, or a range outside its frames.
| Parameter | Type | Description |
|---|---|---|
opts (optional) | {from?: integer, to?: integer, loop?: boolean, on_end?: fun(s: rq.Sprite )} | from (default 1) to to (default the last frame), over again unless loop = false. on_end runs when a play without loop reaches its last frame. |
| Returns | Type | Description |
|---|---|---|
self | rq.Sprite | The sprite. |
Changed in 2.63.0: A Flash file.
rq.Sprite:stop
rq.Sprite:stop() -> rq.Spritesince 1.10.0 changed 2.63.0
Holds the GIF or the Flash file on the frame it is on.
| Returns | Type | Description |
|---|---|---|
self | rq.Sprite | The sprite. |
Changed in 2.63.0: A Flash file.
rq.Sprite:frame
rq.Sprite:frame(n) -> integer|rq.Sprite, integer?since 1.10.0 changed 2.63.0
Returns the frame shown, or shows one and stops.
A Flash file walks its tags to frame n, so a jump in them may show another; the frame read after says which.
Raises an error for a frame outside the GIF or the Flash file.
| Parameter | Type | Description |
|---|---|---|
n (optional) | integer | The frame to show, from 1; leave it out to read. |
| Returns | Type | Description |
|---|---|---|
frame | integer| rq.Sprite | Without n: the frame shown. With n: the sprite. |
count | integer? | Without n: how many frames there are. |
Changed in 2.63.0: A Flash file.
rq.Sprite:playing
rq.Sprite:playing() -> booleansince 1.10.0 changed 2.63.0
Returns whether the sprite's GIF or Flash file is playing.
| Returns | Type | Description |
|---|---|---|
playing | boolean | true while it plays. |
Changed in 2.63.0: A Flash file.
rq.Sprite:to
rq.Sprite:to(opts) -> rq.Spritesince 1.10.0
Moves the sprite from the values it has now to new ones, over time.
A new to takes the place of the one moving, from where it got to, and the old on_end does not run. Sprite:set of a value takes that value out of the motion, and the rest goes on. Removing the sprite ends it too.
Raises an error for a negative ms or delay, an unknown ease, or an on_end that is not a function.
rq.sprite.new({ fill = { 255, 255, 255 }, w = 1024, h = 768, z = "top" })
:to({ alpha = 0, ms = 300, on_end = function(s) s:remove() end }) -- a white flash| Parameter | Type | Description |
|---|---|---|
opts | rq.SpriteMotion | The values and the timing. |
| Returns | Type | Description |
|---|---|---|
self | rq.Sprite | The sprite. |
rq.Sprite:moving
rq.Sprite:moving() -> booleansince 1.10.0
Returns whether a motion is waiting or moving.
| Returns | Type | Description |
|---|---|---|
moving | boolean | true until the motion ends. |
rq.Sprite:halt
rq.Sprite:halt() -> rq.Spritesince 1.10.0
Stops the motion where it is, without its on_end.
| Returns | Type | Description |
|---|---|---|
self | rq.Sprite | The sprite. |
Used by
rq.PlayFlashOpts, rq.Sprite:frame, rq.Sprite:halt, rq.Sprite:play, rq.Sprite:set, rq.Sprite:stop, rq.Sprite:to, rq.SpriteAttach, rq.SpriteMotion, rq.image.play_flash, rq.sprite.list, rq.sprite.new
