Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use/implement pause() to pause a SKAudioNode?

The documentation:

pause()

Creates an action that tells an audio node to pause playback.

Declaration class func pause() -> SKAction

This action may only be executed on an SKAudioNode object. The audio is paused, and if restarted, resumes at where it was paused. This action is not reversible.

Please excuse my ignorance, I simply have no idea how to use this to pause an SKAudioNode, so have not tried any code, and have no code to display, as I don't know HOW to use this, and find this barebones documentation a little too light.

like image 947
Confused Avatar asked Sep 06 '25 09:09

Confused


1 Answers

SKAudioNodes are SKNodes and so are able to run any SKAction. So get a pause action and ask the node to run it (in Swift):

let audio : SKAudioNode
...
let pause = SKAction.pause()
audio.run(pause) 

or shorter:

audio.run(SKAction.pause())
like image 115
Jean-Baptiste Yunès Avatar answered Sep 10 '25 20:09

Jean-Baptiste Yunès