Noob Question ... maybe a java programming problem

Hello !

In my Car Racing Game I have bullets and when I fire hundreds a lot of them I observe a FPS decrease after they shoud have been "disabled", I mean that they aren't anymore in use … the problem might be about "destroying" my object Bullet … here is how I "end" the code of my bullet class:

private void delete() {


After what the physicsSpace contains no phantom objects, neither the scene Node.
Is it a kind of object programming problem ?


u shouldnt delete them, u should reuse them. in other words dont let GC get in the way.

one possible cause might be the GC is doing alot of work and that can significantly cut down ur FPS. u should profile ur game and c if the GC is increasing alot after u fire alot of stuff. i would assume so.

so my suggestion would be maintain them and reuse them later since u will use them later anyways. assuming u gonna keep firing stuff right?

To extend what neakor said… What you could do is create a big array with, say, 1000 bullet objects, and then when you need one, you just modify the next one in the array to have the desired position, speed, etc. and increment your next counter in a circular way (i.e. with wraparound)