I am making an iOS game using Swift. At the menu (Menu is a SKScene), I have a button that starts the game, let's call it 'start button'. When I hit the start button, application freezes and loads the gameplay (gameplay is a SKScene), then transition animation runs and gameplay begins. But instead of the freeze of the application, I want a rotating loading circle while application loads the gameplay. How can I do that? Ask me if there is something not clear...
func loadingScreen(scene:SKScene) {
var loadingSprite = SKSpriteNode(imageNamed: "loading.png")
loadingSprite.size = CGSize(width: 100, height: 100)
loadingSprite.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
loadingSprite.zPosition = 10
self.addChild(loadingSprite)
loadingSprite.runAction(SKAction.repeatActionForever(SKAction.rotateByAngle(3, duration: 0.5)))
let qualityOfServiceClass = QOS_CLASS_BACKGROUND
let backgroundQueue = dispatch_get_global_queue(qualityOfServiceClass, 0)
dispatch_async(backgroundQueue, {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.view!.presentScene(scene, transition: SKTransition.fadeWithDuration(1.0))
})
})
}
And it is the secondScene's initializer;
convenience init (size:CGSize,mode:String) {
self.init(size:size)
self.gameMode = mode
loadItems() //loads my custom objects
printSlider() // printing sprites depending to my objects
}