I create a clone of asteroids, but a few more bells and whistles.
I currently have an ArrayList<Asteroid>
that contains all the asteroids on the screen. Each of them has a Vector
associated with it, and extends my genereic GameObject
class, which handles drawing and updating and other common things that have a common game object.
Every time I destroy an asteroid, I create a new Asteroid
object and add it to ArrayList<Asteroid>
... In this case, there is a noticeable lag, since I also create explosion particles, and I believe that this is GC.
My idea was that instead of creating new objects on the fly, I could pre-create a pool and just reuse them.
Is this the right idea? And what is the most organized and effective way to do this?
Any other ideas would be great. Just trying to reduce the creation of all these objects, because it definitely causes a noticeable lag. Thanks!
source share