我的游戏点是当我触摸屏幕时,游戏开始了。开始时,我有一个移动的玩家和一个目标。如果我在游戏正在播放并且玩家与目标发生碰撞时触摸屏幕,我会得分。在第一级,只有一分得分,所以我击中了目标并直接进入二级。在第二级,在进入三级之前有两个得分。我的问题是,当我第一次开始游戏时,我想要成为第一级,它实际上从级别ZERO开始,然后继续到第一级,这很奇怪......这是我的代码。干杯!
var levelLabel = UILabel()
var levelText = UILabel()
var showLevel = UILabel()
var currentLevel = Int()
var currentScore = Int()
var highLevel = Int()
func targetTouched(){
if intersected == true{
Target.removeFromParent()
addTarget()
intersected = false
currentScore -= 1
levelLabel.text = "\(currentScore)"
showLevel.text = "\(currentScore)"
if currentScore <= 0{
nextLevel()
}
}
else if intersected == false{
died()
}
func nextLevel(){
currentLevel += 1
currentScore = currentLevel
levelLabel.text = "\(currentScore)"
showLevel.text = "\(currentScore)"
won()
if currentLevel > highLevel{
highLevel = currentLevel
let Defaults = NSUserDefaults.standardUserDefaults()
Defaults.setInteger(highLevel, forKey: "highLevel")
}