Contents

playSoundFileNamed(_:waitForCompletion:)

Creates an action that plays a sound.

Declaration

class func playSoundFileNamed(_ soundFile: String, waitForCompletion wait: Bool) -> SKAction

Parameters

  • soundFile:

    The name of a sound file in the app’s bundle.

  • wait:

    If True, the duration of this action is the same as the length of the audio playback. If False, the action is considered to have completed immediately.

Return Value

A new action object.

Discussion

Use SKAction playSoundFileNamed:waitForCompletion: only for short incidentals. Use AVAudioPlayer for long running background music. This action is not reversible; the reversed action is identical to the original action.

See Also

Controlling the Audio of a Node