我想在游戏中具有暂停功能,暂停按钮会加载并显示,但是按下该按钮不会暂停。
//创建暂停按钮
func createPauseButton() {
pauseButton = SKSpriteNode(imageNamed: "pausebutton.png")
pauseButton.size = CGSize(width:50, height:50)
pauseButton.position = CGPoint(x: self.frame.width - 30, y: 30)
pauseButton.zPosition = 6
self.addChild(pauseButton)
}
//开始接触
if pauseButton.contains(location){
if self.isPaused == false{
self.isPaused = true
pauseButton.texture = SKTexture(imageNamed: "play")
} else {
self.isPaused = false
pauseButton.texture = SKTexture(imageNamed: "pausebutton.png")
}
}