Ios 如何在SWIFT、SpriteKIT中切换两个图像以暂停和玩游戏

Ios 如何在SWIFT、SpriteKIT中切换两个图像以暂停和玩游戏,ios,swift,sprite-kit,Ios,Swift,Sprite Kit,我想在两个图像之间切换以暂停并玩我的游戏。我试着使用下面的代码,但不起作用。我将暂停和播放声明为SKSpriteNodes() 有人能帮忙吗 func paused(){ self.scene?.view?.paused = true pause.removeFromParent() } // PLAYING FUNCTION func playing(){ self.scene?.view?.paused = false play.removeFromPar

我想在两个图像之间切换以暂停并玩我的游戏。我试着使用下面的代码,但不起作用。我将暂停和播放声明为
SKSpriteNodes()

有人能帮忙吗

func paused(){
    self.scene?.view?.paused = true
    pause.removeFromParent() 
}

// PLAYING FUNCTION
func playing(){
    self.scene?.view?.paused = false
    play.removeFromParent()      
}

正如其他人告诉你的,你没有提供足够的信息让我们给你一个准确的答案

不管怎样,我能看到的代码的一小部分似乎不适合我

首先,您可能不应该使用两个节点,也不应该删除任何节点。
如果您的目标只是更改图标,则应使用相同的节点,并仅更改其
纹理
属性

如果你想举个例子,我可以给你举个例子

编辑:以下是示例

// In this example, we will call playPauseNode the SKSpriteNode you are using as a button
var isPlaying = true

func buttonTouched() {
if isPlaying { // If the game is playing
playPauseNode.texture = SKTexture(imageNamed: "theNameOfYourPlayButtonImage")
isPlaying = false
}

else { // If the game is paused
playPauseNode.texture = SKTexture(imageNamed: "theNameOfYourPauseButtonImage")
isPlaying = true
}

}

我认为它应该按照您的预期运行…

您没有提供足够的信息。您从场景中删除了
暂停
播放
,但什么时候才能重新添加它们?请这样做,我真的需要帮助才能完成游戏。当我回到家时,我会感谢你的;)