On this page
  1. Fields
    1. playing

rmp::behavior::Animator

behavior #include <rmp/behavior.h> include/rmp/behavior.h:951
struct Animator

Plays the tag that fits what the object is doing: die once its Health is dead, hurt while it is invulnerable after a hit, jump and fall in the air (with gravity), run while it moves and idle while it does not — and mirrors it with flip_x by the way it moves. The names are fields, the tags of your .aseprite; a tag the sheet lacks is skipped for the next that fits, and without a sheet only flip_x is set. Runs after everything has moved.

Added to an object with add<rmp::behavior::Animator>(); the framework calls its _late_update with the object it is on.

Fields

FieldTypeDefaultWhat it is
idlestd::string"idle"

Standing still, on the ground

runstd::string"run"

Moving faster than moving_at

jumpstd::string"jump"

In the air, going up (with gravity)

fallstd::string"fall"

In the air, coming down (with gravity)

hurtstd::string"hurt"

While its Health is invulnerable after a hit

diestd::string"die"

Played once, not looped

moving_atfloat10

Units per second under which it stands still

flipbooltrue

Sets flip_x while it moves left; the art faces right

rulesstd::vector<AnimationRule>

Asked first, in order

oursstruct { … }

What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then { .speed = 320 } stops compiling — which is the whole design. The name is the fence.

playing

std::string_view playing() const

The tag it chose at its last update; "" when it chose none.