0
私はゲームの一時停止ボタンと再生ボタンを作ろうとしていますが、一時停止ボタンをタッチすると画面がちょうどフリーズすることはわかりませんボタン)をタッチし、再生ボタン(フリーズ)をタッチします。フリーズゲームを一時停止/再生する
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
//Pause
pauseButton = SKSpriteNode (imageNamed: "pause")
pauseButton.position = CGPoint(x: self.frame.width/2, y: self.frame.height/2)
self.addChild(pauseButton)
//Play
playButton = SKSpriteNode (imageNamed: "play")
playButton.position = CGPoint(x: self.frame.width/2, y: self.frame.height/2)
//when touch buttons
let touch = touches.first!
if pauseButton.containsPoint(touch.locationInNode(self)) {
addChild(playButton)
pauseButton.removeFromParent()
}
if playButton.containsPoint(touch.locationInNode(self)) {
addChild(pauseButton)
playButton.removeFromParent()
}
}
大変申し訳ございません。 「タッチボタンを押すと」の後に「let touch = touches.first!」を使うのを忘れてしまった。私はdidMoveToViewに移動しようとしましたが、これは私にこのエラーを与えます: "未解決の識別子の使用 'をタッチします。私はコーディングに新しいので、私はそれをほとんど知らない。 =( – Luiz
私は答えを更新しました – crashoverride777
ありがとうございました!!それは働いていました!=) – Luiz