1

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?

Confused
  • 5,839
  • 6
  • 26
  • 65

1 Answers1

1
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)
Martin R
  • 488,667
  • 78
  • 1,132
  • 1,248
  • so... on a scale of 1 to 10, I'm about 8 points worth of deluded? 8.5? – Confused Oct 31 '16 at 12:44
  • oh wise one, do you happen to know anything about this: http://stackoverflow.com/questions/40429475/copied-skaudionode-unresponsive-why, I am clueless, befuddled and confused. – Confused Nov 04 '16 at 18:57