firat.temel
firat.temel

Reputation: 115

How to pause game for a certain time and resume again

I want to pause my game for 2 seconds and continue again. I tried the following but it didn't work.

var duration = NSTimeInterval(2)
var wait=SKAction.waitForDuration(duration)
self.runAction(wait)

self is SKScene. Is there a different method to achieve this?

Upvotes: 1

Views: 236

Answers (1)

rakeshbs
rakeshbs

Reputation: 24572

You can set the SKNode.isPaused property. This is a Boolean value that determines whether actions on the node and its descendants are processed.

This means that if you set self.paused = true in the SKScene, all of the child nodes of the scene will be paused. You can also do it to individual nodes like sprites.

For more information https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKNode_Ref/index.html

Upvotes: 2

Related Questions