May 7, 2011 at 9:26 AM
Edited May 7, 2011 at 9:58 AM
The game I'm currently working on creates/deletes a lot of bodies fairly regularly and after some performance profiling I've found that this is the bottleneck keeping the game from running
at 30fps on WP7 devices. Every meteor and every missile is a sphere body created as the body is being created, so as you can no doubt tell there's a lot of bodies being created/deleted very rapidly.
Is there a way I can optimize past this or do I have to bite the bullet and pre-make all the bodies and set them as I need them?
There's something interesting I found too, the way I was profiling the speed was with the following code:
for(int i = 0; i < 10; i++)
in the update routine and the delay the stopwatch was reporting was going down, so it would say a delay of 500ms, then a delay of 200ms, then a delay of 100ms then a delay of 10ms, then a delay of 500ms (etc, etc).
Any reason for this (I suspect it's the garbage collector)?