HSKAction

public class HSKAction

An action is discrete behavior that can be configured and then run.

Subclasses define specific behavior – see HSKCAAnimation and HSKActionGroup. HSKAction defines the general interace for running an action.

To retrieve an action use LightwellLoadingContext.action(for:):

let loadingContext = LightwellLoadingContext(screenName: "my awesome screen")
let action = loadingContext?.action(for: "action name")

To begin an action, call HSKAction.run():

action.run()

To interupt an already running action, call HSKAction.stop():

action.stop()

To be notified when an action completes, implement the HSKActionDelegate protocol and utilize HSKAction.delegate:

action.delegate = self
...
action.run()
  • The name of the action, and the key for LightwellLoadingContext.action(for:)

    Declaration

    Swift

    public final var name: String?
  • The delegate to notify when the action completes.

    Declaration

    Swift

    public weak var delegate: HSKActionDelegate?
  • A function to begin the action’s configured behavior.

    Calling 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 run()

    See

    stop()

    Declaration

    Swift

    @discardableResult
    public func run() -> `Self`?

    Return Value

    A running copy of the triggering action.

  • Stop a running action.

    Calls to stop an 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.
    

    See

    run()

    Declaration

    Swift

    public func stop()
  • Declaration

    Swift

    public var hashValue: Int { get }
  • Declaration

    Swift

    public static func == (lhs: HSKAction, rhs: HSKAction) -> Bool