public class HSKAction
An action is discrete behavior that can be configured and then run.
To retrieve an action use
let loadingContext = LightwellLoadingContext(screenName: "my awesome screen") let action = loadingContext?.action(for: "action name")
To begin an action, call
To interupt an already running action, call
action.delegate = self ... action.run()
The name of the action, and the key for
public final var name: String?
The delegate to notify when the action completes.
public weak var delegate: HSKActionDelegate?
A function to begin the action’s configured behavior.
run()will create a copy of the action that performs the behavior. This way a single action can be run multiple times, each time performing the same behavior:
// Jump jumpAction.run() // Jump higher jumpAction.run() // Jump very high jumpAction.run()
It also means that you can use an action as a model and make slight tweaks before calling it again:
animationAction.run() animationAction.duration = 10 animationAction.run()
Or you can modify just the running action as it runs.
let runningAction = triggeringAction.run() runningAction.name = "running action"
Note that while the running action is editable, depending on the type of action and the property being edited, some edits may be ignored after calling
@discardableResult public func run() -> `Self`?
A running copy of the triggering action.
Stop a running action.
stopan action that hasn’t started, or has already ended are safe and is a no-op.
Stopping a running action will stop that single instance, whereas stopping the triggering action will stop all running actions triggered by that action:
let firstRunningAction = triggeringAction.run() let secondRunningAction = triggeringAction.run() // Stop first firstRunningAction.stop() // Second is still running
let firstRunningAction = triggeringAction.run() let secondRunningAction = triggeringAction.run() // Stop both triggeringAction.stop() // Both first and second have stopped.
public func stop()