On this page
  1. texture
  2. sheet
  3. source
  4. origin
  5. size
  6. tint
  7. speed
  8. Animation, when there is a sheet
  9. play, stop, finished, playing
  10. frame_index, set_frame
  11. ours

rmp::Sprite

struct #include <rmp/object.h> include/rmp/object.h:103
struct Sprite

What an Object draws in place of its shape when it has one: a texture or a sheet, placed by origin around the object's position and turned, scaled and flipped with the object. A sheet also animates; play() picks the tag.

texture

rmp::Texture texture

A loose picture, when there is no animation

sheet

rmp::SpriteSheet sheet

An .aseprite; sheet wins over texture

source

Rectangle source{}

{0,0,0,0} = the whole texture, or the sheet's frame

origin

Vector2 origin{ 0.5f, 0.5f }

NORMALISED, and centred by default

size

Vector2 size{}

{0,0} = the source's own size

tint

Color tint = WHITE

Multiplies the picture's colours; WHITE leaves them as they are

speed

float speed = 1.0f

2 = twice as fast, 0 = frozen, -1 = backwards

Animation, when there is a sheet

play, stop, finished, playing

void play(std::string_view tag, bool loop = true)
void stop()
bool finished() const
std::string_view playing() const
player.sprite.sheet = rmp::assets::load_sheet("player.aseprite");
player.sprite.play("walk");     // "walk" is a tag of YOURS

A literal, a std::string or a std::string_view, as it comes. playing() hands back the sheet's own name for the tag, or "" when nothing plays: valid for as long as the sheet is loaded, and the characters after it are a NUL, which tests/animation_test.cpp holds it to.

A tag that is not in the sheet WARNS ONCE and does nothing — it does not land on a blank frame, and it does not fill the console sixty times a second saying so.

frame_index, set_frame

int frame_index() const
void set_frame(int index)

The escape hatch: drive the frames yourself.

ours

struct { … } ours

What it is keeping track of. See the note on ours in rmp/behavior.h: public because a private member would stop this being an aggregate.