简体   繁体   English

Swift中的分数乘数

[英]Score Multiplier in Swift

I have an application that adds one to the score whenever you tap anywhere on the view. 我有一个应用程序,只要您在视图上的任意位置点击,就可以将分数加一。 I would like to have a score multiplier that states that whenever the user is tapping faster his or her score will not just increment by one, but by a larger amount depending on how fast and/or how long they have been tapping. 我想有一个分数乘数,该分数表示用户每次快速点击时,他或她的分数将不仅会增加一个,而是会根据他们被点击的速度和/或时间长短而增加更多。 I've done a good bit of Googling but I have yet to find anything. 我在Google上做了很多工作,但还没有找到任何东西。 Thanks in advance 提前致谢

Without further examples its hard to actually give you help, here is a stab 没有更多示例,很难实际提供帮助,这是一个刺

static let multiplier = 1000

struct Player {

  var score: Int
  var displayScore: Int {
    return score * multiplier
  }

}

var player = Player(score: 1)
print(player.displayScore) // 1000
player.score += 1
print(player.displayScore) // 2000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM