On the weekend if I'm working I like to count it as "Treat days", where I get to dick around with things I don't really have time for.
This weekend I updated the skybox to a much nicer collection of 1024x1024 textures and to celebrate I added some parallax stars.
The stars had to be away3D sprites as they needed to go behind the planets ( That took ages, 3D positioning isn't my strong suit ).
It looks lovely with a 100 stars, really nice and subtle, but as ever the iPad isn't going to cope with that. When I was testing though I did notice a one frame hold up when a baddie was killed ( The new stars actually really helped with the testing of this, I could see them jitter, which is something which I was missing with just the planets / skybox in there ).
Today has been spent trying to optimise things to avoid that judder. It was a case of removing every element of the explosion until I found the bottle neck, which it turned out are the particles.
So I've removed one of the explosions ( Down to 3 from 4 ), capped their max size as they grow in size depending on the beat of the music, reduced the number of particles which are belched out and done some loop unrolling in Starling itself.
A couple of things I noticed, with the particles I could pre-calc pretty much everything, their speed / rotation / speed and store all those values in Vectors in the constructor so their actual movement / scaling is just a case of getting values from a Vector, which helped. The code per particle is really cut down now.
Also with my alteration in Starling to keep the visible / invisible display objects in their own Vectors ( More here ) I found that there could be really large loops due to the number of children in the game, so I've unrolled some loops there. I think I need to do some more work though, as triggering 34 particles at once means a lot of looping to move the sprite from the hidden to visible Vector. There's got to be a smarter way to do that.
All these amends still haven't got rid of the tiny judder, I don't think it's going to be possible and I'm not that gutted about it, I'm developing on the slowest on the market iPad ( 3 ), and I added an additional check that if there are more than 20 particles running at once then I hide these new sexy parallax stars. It may sound nasty, but they're really tiny and it gives the impression that they're blinking ( Also if there are explosions kicking off on screen you're not going to notice anyway ).
Have I go time to mention retro mode ? No, ok, let's save that for now then.