Overview
RiveStateMachineInstance represents an instance of a state machine within a Rive artboard. State machines provide interactive control over animations through inputs, handle events, and support touch interactions.
Properties
The view model instance bound to this state machine (read-only, nullable).
State Machine Information
name
Returns the name of the state machine.The state machine’s name as defined in the Rive file.
Playback Control
advanceBy:
Advances the state machine by the specified elapsed time.The time in seconds to advance the state machine.
Returns true if the state machine needs to keep advancing, false otherwise.
Input Management
getBool:
Retrieves a boolean input by name.The name of the boolean input.
The boolean input, or nil if not found.
getTrigger:
Retrieves a trigger input by name.The name of the trigger input.
The trigger input, or nil if not found.
getNumber:
Retrieves a number input by name.The name of the number input.
The number input, or nil if not found.
inputNames
Returns the names of all inputs in the state machine.Array of input names.
inputCount
Returns the number of inputs in the state machine.The number of inputs.
inputFromIndex:error:
Returns an input by its index.Zero-based index of the input.
Pointer to an error object that will be set if the operation fails.
The input at the specified index, or nil if an error occurs.
inputFromName:error:
Returns an input by its name.Name of the input.
Pointer to an error object that will be set if the operation fails.
The input with the specified name, or nil if an error occurs.
Layer and State Management
layerCount
Returns the number of layers in the state machine.The number of layers.
stateChangedCount
Returns the number of state changes that occurred in the last advance.The number of state changes.
stateChangedFromIndex:error:
Returns a layer state that changed by its index.Zero-based index of the state change.
Pointer to an error object that will be set if the operation fails.
The layer state at the specified index, or nil if an error occurs.
stateChanges
Returns the names of all states that changed.Array of state names that changed.
Event Handling
reportedEventCount
Returns the number of events reported by the state machine since the last frame.The number of reported events.
reportedEventAt:
Returns a reported event by its index.Zero-based index of the reported event.
The event at the specified index.
Touch Interaction
RiveHitResult Enum
Represents the result of a touch interaction.No hit detected.
Hit detected on a transparent area.
Hit detected on an opaque area.
touchBeganAtLocation:
Notifies the state machine that a touch began.The touch location in the coordinate space of the artboard.
The hit result of the touch.
touchBeganAtLocation:touchID:
Notifies the state machine that a touch began with a specific touch ID (for multitouch support).The touch location in the coordinate space of the artboard.
A unique identifier for the touch event.
The hit result of the touch.
touchMovedAtLocation:
Notifies the state machine that a touch moved.The touch location in the coordinate space of the artboard.
The hit result of the touch.
touchMovedAtLocation:touchID:
Notifies the state machine that a touch moved with a specific touch ID.The touch location in the coordinate space of the artboard.
A unique identifier for the touch event.
The hit result of the touch.
touchEndedAtLocation:
Notifies the state machine that a touch ended.The touch location in the coordinate space of the artboard.
The hit result of the touch.
touchEndedAtLocation:touchID:
Notifies the state machine that a touch ended with a specific touch ID.The touch location in the coordinate space of the artboard.
A unique identifier for the touch event.
The hit result of the touch.
touchCancelledAtLocation:
Notifies the state machine that a touch was cancelled.The touch location in the coordinate space of the artboard.
The hit result of the touch.
touchCancelledAtLocation:touchID:
Notifies the state machine that a touch was cancelled with a specific touch ID.The touch location in the coordinate space of the artboard.
A unique identifier for the touch event.
The hit result of the touch.
touchExitedAtLocation:
Notifies the state machine that a touch exited the artboard.The touch location in the coordinate space of the artboard.
The hit result of the touch.
touchExitedAtLocation:touchID:
Notifies the state machine that a touch exited the artboard with a specific touch ID.The touch location in the coordinate space of the artboard.
A unique identifier for the touch event.
The hit result of the touch.
Data Binding
bindViewModelInstance:
Binds an instance of a view model to the state machine for updates. A strong reference to the instance being bound must be made if you wish to reuse instance properties or for observability. By default, the instance will also automatically be bound to the artboard containing the state machine.The instance of a view model to bind.