Let's say I begin with a scene initialScene
. This scene contains a few buttons. When the user taps Button A in this scene, I will present sceneA
. So my code would look like this:
sceneA* scene = [[sceneA alloc] init];
[self.scene.view presentScene: scene];
My first question is, when an instance of sceneA
is presented from initialScene
, is it stacked on top of the initialScene
instance or does it replace it? Does the instance of initialScene
get deallocated in memory when a new scene is presented ?
I ask this because sceneA
will have a Back Button which, when tapped, returns the user to the initial scene. Can I just create a new instance of initialScene
within sceneA
and present it, or will that result in multiple instances of the same scenes stacked on top of each other? Basically, can I just do this in sceneA
?:
if(...) { //if user taps back button
initialScene* iniScene = [[initialScene alloc] init];
[self.scene.view presentScene: iniScene];
}
Or is there a better way to do this? Please let me know if there is any way I can clarify this further.
Sprite Kit makes it easy to transition between scenes. You can either keep scenes around persistently, or dispose of them when you transition between them. In this example, you create a second scene class to learn some other game behaviors. When the “Hello, World!” text disappears from the screen, the code creates a new scene and transitions to it. The Hello scene is discarded after the transition.
Sprite Kit Programming Guide
https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/GettingStarted/GettingStarted.html#//apple_ref/doc/uid/TP40013043-CH2-SW10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With