Reputation: 1852
I'm currently developing a swift spritekit game and wanted to make
add a "Tap to Start" button that you will have to touch to start the game.
I wanted to add this feature since the game just starts right after transitioned to the GameScene, I want to give the user to tap this "Tap to start" instead of just starting instantly, so I was trying to add a scene.view.paused = true
inside the didMoveToView and run the game when the "Tap to start " is pressed. The problem is when the script above inside didMoveToView method, the game wont load when transitioned. So how will I stop the game after being transitioned to the gameScene ? Since I'm new to swift and Spritekit , I would love to hear some tips and samples from you!
//var stopped : Bool = false
override var paused : Bool{
didSet {
if(stopped && !paused) {
paused = stopped
}
}
}
Tried to call the Pause method inside didMoveToView
Upvotes: 0
Views: 190
Reputation: 1213
The game won't load because scene.view.pause = true
pauses everything, from actions to spawning in objects. The best way to achieve your goal is to create a non moving game and in the touchesBegan()
method, start your game.(add the move actions to your objects). If this sounds to complicated, you can also pause all actions with: self.speed = 0.0
. This pauses actions, but does not pause spawning.
If you still can't get it to work, post some more code and I will see what I can do to help you.
Upvotes: 1