StateMachineInstance is the unit of playback in C++:
Advancing
advanceAndApply(dt) runs solvers (state machine, animations, layout, data
bindings) for dt seconds and applies the results to the artboard’s
component graph. Call it before every draw:
true means the state machine is still animating and the next
frame should re-draw. false means everything has settled.
Forcing a Layout Pass
Passdt = 0 to re-solve layout without advancing time. Useful right after
resizing the window or changing the artboard’s width() / height():
Pointer Events
A state machine listens for pointer events onListener components placed
in the editor. Map your window-space coordinates into artboard-local
space before forwarding:
HitResult returns one of three values, which tells you how to route the
same event to other UI behind Rive:
none— the event passed through Rive without firing a listener. Forward it to whatever UI is behind.hit— a listener fired, but the shape it’s on is transparent. Rive isn’t blocking the event; forward it as well.hitOpaque— a listener fired and the shape is opaque. Rive consumed the event; don’t forward.
Reading State Changes
After eachadvanceAndApply you can introspect what happened on a
StateMachineInstance. Call directly on your StateMachineInstance:
.riv
file — log analytics, play a sound, fire a callback into your engine.