Swift3 - Spritekit精灵不是全尺寸

时间:2017-04-27 12:11:51

标签: swift3 sprite-kit skspritenode

我希望在屏幕上弹出一个游戏,使用SKSpriteNodes并在第一次尝试时正确缩放,但从第二次开始,整个游戏过程都很小。

func spawnPlayAgainBTN() {
    playAgain = SKSpriteNode(imageNamed: "buttonPlay")
    playAgain.position = CGPoint(x: self.frame.midX + 54, y: self.frame.midY - 10)
    playAgain.zPosition = 8
    playAgain.setScale(0)
    self.addChild(playAgain)
    playAgain.run(SKAction.scale(to: 0.4, duration: 0.4))

}

func spawnMainMenuBTN() {
    mainMenu = SKSpriteNode(imageNamed: "buttonMainMenu ")
    mainMenu.position = CGPoint(x: self.frame.midX - 54, y: self.frame.midY - 10)
    mainMenu.zPosition = 8
    mainMenu.setScale(0)
    self.addChild(mainMenu)
    mainMenu.run(SKAction.scale(to: 1.0, duration: 0.4))
}


func spawnGameOverScreen() {
    gameOverBG = SKSpriteNode(imageNamed: "gameOverBG")
    gameOverBG.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
    gameOverBG.zPosition = 7
    gameOverBG.setScale(0)
    self.addChild(gameOverBG)
    gameOverBG.run(SKAction.scale(to: 1.0, duration: 0.4))
    spawnPlayAgainBTN()
    spawnMainMenuBTN()
    isRunningGame = false
    isShowingGameOver = true
}

0 个答案:

没有答案