I'm creating a platform type of game with various types of platforms. Platforms that move, shake, rotate, etc. Multiple types and multiple of each type can be on the screen at once. The platforms will be procedural generated.
I'm trying to figure out which of the following would be a better platform system:
Pre-allocate all platforms when the scene loads, storing each platform type into different platform type arrays( i.e.
regPlatformArray), and just getting one when I need one.
The other option is to allocate and load what I need when my code needs it.
The problem with 1 is keeping up with the indices that are in use on screen and which aren't.
The problem with 2 is I'm having a hard time wrapping my head around how I would store these platforms so that I can call the update/draw methods on them and managing that data structure that holds them. The data structure would constantly be growing and shrinking. It seems there could be too much complexity.
I'm using the cocos2d iPhone game engine.
Anyways, which option would be best or is there a better option?