需要帮助弄清楚如何连续播放歌曲

时间:2019-04-08 23:13:05

标签: ios swift

这是一款战争纸牌游戏应用,当您按交易时,Rick会滚动您。在应用程序中一切正常。我只是想不出如何防止用户每次按下按钮都重新开始播放歌曲。

@IBAction func dealTapped(_ sender: Any) {
    playBackGroundMusic(fileNamed: "Rick Astley - Never Gonna Shoot Your Stars.mp3")

    let leftNumber = Int.random(in: 2...14)
    let rightNumber = Int.random(in: 2...14)

    leftImageView.image = UIImage(named: "card\(leftNumber)")
    rightImageView.image = UIImage(named: "card\(rightNumber)")

    if leftNumber > rightNumber {
        leftScore += 1
        leftScoreLabel.text = String(leftScore)
    } else if leftNumber < rightNumber {
        rightScore += 1
        rightScoreLabel.text = String(rightScore)
    } else {

    }

0 个答案:

没有答案