Skip to main content
An action performed when an associated State Machine Listener is triggered. For more information, see Listener Action Scripts.

Methods

init

init((self: T, context: Context) -> boolean) Called once when the listener is created or attached.
type MyListenerAction = {}

-- Called once when the script initializes.
function init(self: MyListenerAction, context: Context): boolean
  return true
end

function perform(self: MyListenerAction, pointerEvent: PointerEvent) end

return function(): ListenerAction<MyListenerAction>
  return {
    init = init,
    perform = perform,
  }
end

perform

perform(pointerEvent: PointerEvent) -> () Called when the associated State Machine Listener is triggered. This method includes a PointerEvent parameter containing details about the triggering interaction.
type MyListenerAction = {}

function init(self: MyListenerAction, context: Context): boolean
  return true
end

-- Add your transition logic here.
-- `evaluate` is fired every frame while the transition is active.
-- Returning false prevents a transition, true allows a transition.
function perform(self: MyListenerAction, pointerEvent: PointerEvent)
  return true
end

-- Return a factory function that Rive uses to build the Listener Action instance.
return function(): ListenerAction<MyListenerAction>
  return {
    init = init,
    perform = perform,
  }
end