【问题标题】:Play interstitial ad every 3rd game in Swift在 Swift 中每 3 场比赛播放一次插页式广告
【发布时间】:2015-10-21 20:30:18
【问题描述】:

我在这里找到了一个可以接受的 Objective-C 答案:

Play interstitial ad every 3rd game

但是,我正在尝试在 Swift 中做同样的事情。我正在研究如何编写静态变量。

这是 Objective-C 代码:

static int count = 0;

-(void) GameOver {
   if(count != 0 && count % 3 == 0)
     [HZInterstitialAd show];

   count++;
}

【问题讨论】:

    标签: ios swift sprite-kit heyzap


    【解决方案1】:
    private var count = 0
    
    func GameOver {
      if (count != 0 && count % 3 == 0) {
        HZInterstitialAd.show()
      }
      count++
    }
    

    【讨论】:

    • 太棒了。我一直在寻找 Swift 中的静态等效项。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多