0
我在不同的關卡創建了一款遊戲。如果用戶達到特定的gameScore,alertButton應該彈出(已經工作),但只要用戶切換場景,按鈕應該消失。用我的代碼,按鈕不會消失。我如何讓圖像只出現一次?如何添加轉換後消失的圖像?
這裏是我的代碼:
var alertButton = SKSpriteNode.init(imageNamed: "AlertButton")
var totalGameScore = 0
class Game: SKScene {
override func didMove(to view: SKView) {
if totalGameScore > 50 { //alert button appears and should disappear after scene changes
self.addChild(alertButton)
}
if totalGameScore > 100 { //alert button appears again and should disappear after scene changes
self.addChild(alertButton)
}
}
}