Swift 3 sound play

前端 未结 4 1109
我在风中等你
我在风中等你 2021-02-01 22:33

Ok I have looked into this and have tried many different ways to play a sound when a button is clicked.

How would I play a sound when a button is clicked in swift 3? I h

4条回答
  •  你的背包
    2021-02-01 23:14

    A much easier way to do this is to put the following line of code in your button pressed function (Note: Only works in sprite kit):

    run(SKAction.playSoundFileNamed("ClickSound.mp3", waitForCompletion: false))
    

    Hope this helps :)

提交回复
热议问题