I've started on a new project in which the level geometry is instantiated randomly/procedurally.
Objects are created beyond camera view and when they pass behind the player they are destroyed.
On the iPhone the game starts smoothly at around 40fps but there is a gradual slow down. After two minutes the scene is really chugging.
I'm wondering what is causing the deterioration in speed? I've double checked that every clone is getting destroyed once out of sight and the game reaches a maximum of about 60 objects and handles this fine initially.
Could this be something to do with instatiate and destroy on a constant basis? In my previous game, Surveillant I used these functions only occasionally.
I've just built an alternate version, where all the objects are instanced on startup - no destroy or instantiate takes place during play. It runs at a constant rate without any slowdown. This leads me to believe using instantiate/destroy every update is causing the slowdown. Seems a shame, as instantiate/destroy worked fine to generate my random landscape. However I reckon I can write a work-around to achieve the same effect without using the two functions.
Anyone know why instantiate/destroy causes this gradual slow down exactly or how to patch it?
answered May 23 '11 at 03:39 PM