How can I know when the SKScene is fully loaded to make a "loading ..." screen?

1

The scene executes all the functions, but in old equipment (such as the 4S or 5C) the nodes are delayed for about 2 seconds (sometimes a little more or a little less)

I print:

print("antes")
//sprites y matrixSprites son SKSpriteNode
sprites.addChild(matrixSprites)
print("después")

The two print are printed in the console, 2 seconds pass and the elements that are in the sprites node are displayed on the screen. There is some way of pre-loading the scene and knowing if all the elements are visible in the scene, such as to make a "loading ..." screen.

    
asked by albertcito 24.06.2016 в 00:47
source

1 answer

1

You can use SKActions to then use completion , I'll explain it in code:

print("antes")

let render = SKAction.run({
     sprites.addChild(matrixSprites)
})

self.run(render, completion: {
    print("después")
})

The idea of this is to leave an action defined within the "render" variable, this will be executed by the self.run (SKScene.run) method and once it is fully executed then it will execute the code statements that you define, in the case of the example a print ("after")

    
answered by 16.10.2016 / 00:35
source