【发布时间】:2017-06-09 20:13:01
【问题描述】:
我创建了一个 func counter() 并在其中包含 seconds -= 1 和 label.text。我试图制作一个 if marioButtonPressed(sender: AnyObject) [my button for the app] { seconds += 0 } 但无法推断出通用参数“T”。任何帮助将不胜感激。如果需要,我可以提供更多信息。
func counter()
{
seconds -= 1
label.text = String(seconds) + ""
*if marioButtonPressed(<#T##sender: AnyObject##AnyObject#>) {seconds += }*
if (seconds == 0)
{
timer.invalidate()
gameOver.isHidden = false
UIView.animate(withDuration: 1, animations: {
self.gameOver.center = CGPoint (x: self.gameOver.center.x + 500, y: self.gameOver.center.y)})
}
}
我有错误的代码。
另外,如果计时器达到 0,我的按钮将停止工作,我该如何做到这一点?
【问题讨论】:
-
编辑您的问题以包含
marioButtonPressed的定义。