# rmp::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.

Source: https://omardev29.github.io/rmp-docs/reference/classes/rmp-Sprite.html

struct `#include <rmp/object.h>` [include/rmp/object.h:103](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L103-L144)

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

field [include/rmp/object.h:104](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L104)

A loose picture, when there is no animation

### `sheet`

rmp::SpriteSheet sheet

field [include/rmp/object.h:105](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L105)

An .aseprite; `sheet` wins over `texture`

### `source`

Rectangle source{}

field [include/rmp/object.h:106](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L106)

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

### `origin`

Vector2 origin{ 0.5f, 0.5f }

field [include/rmp/object.h:107](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L107)

NORMALISED, and centred by default

### `size`

Vector2 size{}

field [include/rmp/object.h:108](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L108)

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

### `tint`

Color tint = WHITE

field [include/rmp/object.h:109](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L109)

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

### `speed`

float speed = 1.0f

field [include/rmp/object.h:110](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L110)

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

function [include/rmp/object.h:125](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L125)

```cpp
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)

function [include/rmp/object.h:131](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L131)

The escape hatch: drive the frames yourself.

### `ours`

struct { … } ours

field [include/rmp/object.h:136](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L136-L143)

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.
