The docs seem to suggest that running play on an SKAudioNode returns an SKAction
play() Creates an action that tells an audio node to start playback.
class func play() -> SKAction
So my wee logic tells me I can get at this returned Action, and assign it to a variable or constant like this:
var mySoundAction = mySoundNode.run(SKAction.play())
But Xcode tells me I'm an idiot and have no idea what I'm doing when I try to do this:
self.run(mySoundAction)
It tells me it's unable to convert a type of void to that of an SKAction.
What am I doing wrong? How deluded am I in my goals to have an action name for something like this?
SKAction.play()
returns an SKAction
, and
mySoundNode.run(SKAction.play())
runs that action on mySoundNode
. The run()
method returns Void
("nothing"), so with
var mySoundAction = mySoundNode.run(SKAction.play())
you run the "play" action on the node and assign ()
to var mySoundAction
. What you perhaps meant is
var mySoundAction = SKAction.play()
// ...
self.run(mySoundAction)