Hi guys! I am inches away from releasing my game but the last problem remains.
I've done a pass on the game to minimise GLOBALS, where I have them I localise them before use etc... I've double checked my array loops on onEnterFrame and made sure I'm calling as much as I can on update with self (GameScene).
My issue is that the first round runs relatively well but subsequent retries and further rounds get slower and slower. I'm nilling everything I can get my hands on (GAME, self.world, self.player, self.rt etc...) in the gameOver() but it doesn't seem to be helping.
Is there a clean-up function I can use? Do I need to transition to a different scene first? Or manually mop up every child in self.game before I move?
I'm also calling collectgarbage("collect") on init() and gameOver(), is that a bad idea?
I'm sort of stretching the framework here so I don't have a lot of room to maneuver (lots of getPixel() calls to draw on my render target) but the first scene always behaves itself, it's just the scene reset seems to be holding onto some stuff I guess.
sceneManager:changeScene(scenes[3], 1, SceneManager.fade, easing.linear) |
is what I'm using to make the transition to another round or reload the current one.
Comments
I'm guessing sceneManager isn't getting rid of that stuff automagically?
But if that's the case, does it mean I need to go around killing all my textures and sounds etc...? I would have assumed that's baked into sceneManager...
And again, is nilling sufficient or should I be removeChilding it first?
With bump for example...
For example your enemies class. In my opinion it is so much easier to make it global. I would have something like..
In your scenes you need to stop all of their listeners. Here is the basic game scene that I use, where I remove my listeners in onTransitionOutBegin()
Hopefully I've provided a little insight. All these topics and more will be in my Gideros EBook when I finish it
Likes: Apollo14, Astirian
In retrospect, I think maybe Apple's SpriteKit is very forgiving with memory management and scene transitions and so on but teaches some baaad habits. I like being responsible for my class uhm... cleanliness?
So it looks like I have more work to do, just when I thought I had it licked, more learnings are to be had, you're like a Gideros Yoda man.
I will most assuredly be buying your book when it's finished!
Likes: antix, Apollo14
Likes: Astirian
Likes: antix, Astirian