我無法理解我的邏輯有什麼問題。它似乎工作得很好,直到我用幾種方法對應用程序進行了一些更改,以發現烏龜移動得太快。即使GameScene的Update方法沒有結束,我也會得到「You Lose」
我在遊戲開始後的幾秒鐘內收到「You Lose」,計數增加。敵人還沒有碰到我的精靈,它仍然失去了。我在過去的24小時內打破了我的頭來解決這個問題。
的代碼類似於雷Wenderlich殭屍康加
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
if lastUpdatedtime > 0 {
dt = currentTime - lastUpdatedtime
} else {
dt = 0
}
lastUpdatedtime = currentTime
//println("\(dt*1000) milliseconds since last update")
//Tartuga.position = CGPoint(x: Tartuga.position.x + 4 , y: Tartuga.position.y)
boundsCheckTartuga()
rotateSprite(Tartuga, direction: CGPoint(x:22, y: 300),rotationRadiansPerSdec: 3)
//stopTartuga()
mandateFall()
if lives <= 0 && !game0ver {
gameOver = true
println("you lose!")
let reveal = SKTransition.flipHorizontalWithDuration(0.5)
}
搜索您的代碼以查找更改「lives」和「game0ver」值的任何位置。 「生命」的某個地方正變爲0或負值,「givever」是錯誤的。 – rmaddy 2015-01-15 17:52:01
您可能想要檢查您的更新時間。檢查多久調用一次以及爲什麼。顯然這是對條件語句的要求,所以我猜這就是原因,除非你在其他地方設置了gameOver。 – TheCodingArt 2015-01-15 17:54:00