Greets folks.
I’m trying to work out some issues in my animation loop. I can post code if desired; however, I’m not really sure the code is helpful just yet.
I need to figure out a way to determine a) how to know if objects are being created, b) how to know WHERE objects are being created, and c) how to eliminate object creation in my animation thread.
That said, let me give you the psuedo code.
Most of my graphics are stored as an Image in an Image[] so that I can access them by index. I have precalculated transitions on my ground terrain, so the procedure for drawing transition tiles is straight lookup. My loop looks like:
drawTerrain()
drawTransitions()
drawBackgrounds() // stuff like rocks, etc.
drawForegrounds() // trees, and characters
I am not sure why, but there is a significant hesitation every once in a while. I am almost positive it is related to garbage collection, but I have no idea what garbage I am creating that would need to be collected!
Reference information: this is running in Java 1.3.1, on a JPanel that is 512x512. I maintain a primitive array of two BufferedImages that are used as offscreen buffers so that I can start drawing on the next one as the first one is drawn to the screen. I did this because at one point I was not sure that the drawing loop would complete in the time it takes to draw the buffer to the screen. The BufferedImages are optimized as per other threads on this board to minimize the impact of transparency on them; I believe they are RGB BufferedImages with no alpha. The terrains are RGB, the transitions and backgrounds and foregrounds and chars are all ARGB.
Any help is most graciously appreciated.