2 Replies
      Latest reply on Dec 14, 2018 10:02 PM by CartoonSmart.com
      Zwolf71 Level 1 Level 1 (0 points)

        Hi,

         

        I am trying to add sound to a sequence.

         

        First, in GameScene.swift in func didMove (after creating the mySprite of course), I added the property to the sequence:

         

        let demoAction = SKAction.move(to: CGPoint(x: 450, y: 300), duration: 3)

        let growAction = SKAction.scale(to: 3, duration: 3)

        let dialogueOne = SKAction.playSounfFileNamed("DialogueOne.m4a", waitForCompletion: false)

        let sequence = SKAction.sequence([demoAction, growAction, dialogueOne])

        mySprite.run(sequence)

         

        ...and this didn't work.

         

        Then in GameScene.swift I added the property (globally):

         

        let dialogueOne = SKAction.playSounfFileNamed("DialogueOne.m4a", waitForCompletion: false)

         

        and called it at the end of the function:

         

        let demoAction = SKAction.move(to: CGPoint(x: 450, y: 300), duration: 3)

        let growAction = SKAction.scale(to: 3, duration: 3)

        let sequence = SKAction.sequence([demoAction, growAction])

        mySprite.run(sequence)

        self.run(dialogueOne)

         

        ...this also didn't work.

         

        I also imported AVFoundation in both GameViewController.swift and GameScene.swift btw - not sure if this was necessary.

         

        The sequence works without the sound. How can I add sound to a sequence?

         

        Thanks

         

        h