On this page
  1. Fields
    1. finished
    2. restart

rmp::behavior::Tween

behavior #include <rmp/behavior.h> include/rmp/behavior.h:300
struct Tween

Moves one property of its object from from to to over seconds, along an Ease. With neither loop nor ping_pong it stops exactly on to and finished() turns true.

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

Fields

FieldTypeDefaultWhat it is
propertyPropertyProperty::POSITION_Y

The field it writes

fromfloat0

The value at the start of a pass, in that field's unit

tofloat0

The value at the end of a pass

secondsfloat1

How long one pass takes; 0 = straight to to

easeEaseEase::IN_OUT

The curve of each pass

loopboolfalse

Start again from from at the end of each pass

ping_pongboolfalse

Turn back at each end, forever; wins over loop

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.

finished

bool finished() const

Whether it has stopped on to: a tween with neither loop nor ping_pong does at the end of its pass, and one of 0 seconds at once, whatever those two say.

restart

void restart()

Starts it again from from, going forwards, as if it had just been added.