Hello,
I'm kind of in the end stages of this game that I'm developing, and I have a question about how to help performance.
The game runs all right, but it kind of hiccups every once in a while, and I'm trying to limit that as much as possible. Basically there's a bit of a lag in the fps down to about 40, then it goes back up, and I can kind of tell with the way my box2d objects are moving.
Anyway, a bunch of objects (fairly small - like 20x20px I think) fly down the screen. I use the box2d applyforce or applyimpulse or whatever it is to the objects to get them moving, and they are in 0 gravity. So, they move at a constant speed.
Anyway, there are anywhere from 1-6 of these objects on the screen at any given time. I also have a few ground objects setup so I can detect when the falling objects need to be removed, and I remove them when they touch these ground objects.
Right now I am creating these objects on the fly as I need them. For each level, there are about 20-200 objects total.
Now, the question is, should I create all of the objects at once, make them sleep in box2d or something, and then wake them up and push them when it's their turn to be used, or should I continue creating them on the fly?
Basically, does it take a lot of processor power to create these objects? I am using CCSpriteSheet for them and creating the box2d fixture and everything when I need them. Would it use less processor power and lag less to create them all first than it would by creating them on the fly?
I think I am actually going to answer my own question here. I think, as long as I don't use up all of the memory available, and I make sure the objects are asleep in box2d, it's probably best to create all of the objects first and then use them when I need them.
Still, I am going to post this so I can get some feedback, and maybe this thread will help someone else out in the future.
Thanks for any input!