Hey everyone I’m very new to Java game development and trying to build a simple top-down zelda-style game. It’s coming along nice and I got all the collision checking, movement and attacking working properly. I think my question is pretty simple:
I have an Animation class which holds an array of images.
I have a drawToTheScreen array which holds a list of Animations.
Everytime the “paint” method is called it goes through that list & draws what’s necessary.
Everything is working fine.
Every time I cut a bush it creates a new Animation object with the Bush being cut up images. Once it finishes the animation it removes itself from the list to be drawn to the screen.
Now there are going to be a lot of bushes you can cut up. If every bush is creating a new Animation object won’t there be a lot of no-longer-used memory being taken up? I know Java takes care of memory itself but is there anyway I can explicitly say “Hey java I’m never going to use this Animation object again after it’s taken off of the drawToTheScreen Array?”. Or by taking it off of the array will Java magically know that I no longer want to store that in memory and I’m not going to use it again?