Currently, I'm using an SKS file to set up my sprite locations via empty nodes or in some instances I am actually dragging and dropping the sprite into the scene editor. After having some loading issues, I was advised to preload all of the textures via a texture atlas. One issue that I came across before moving to this scheme was that my didMoveToView method was using more and more memory every time a scene loaded and reloaded. I have 3 scenes in my SpriteKit game: a main menu, level select and level scene. How should my scenes be managed? Should I create an instance of each and store them globally to avoid using too much memory? Currently, each scene is capable of initializing and calling presentScene. With my level scene there's a good amount of setup that needs to be done and when loading from the level selection scene I'm not sure if this should be recreated over and over again. I hope this is clear as to what I'm asking. Thanks in advance.
0
votes
1 Answers
0
votes
SK does all of its memory management and caching behind the scenes. You really have no control over any of it. Short of your code having a memory leak or retain cycle somewhere, your app's memory usage will top out at a certain point.
If you want, you can manually 'nil out' all scene objects and [self removeAllChildren]; in the -(void)willMoveFromView:(SKView *)view method.