Quote:Original post by SnotBob
I had no idea that there was a slow motion feature. You might wish to place that note closer to the center of the screen and in a bigger font.
BTW, The jerk appears even when I click on an empty spot, when the explosion circles don't appear. What are you doing in response to the mouse release event? I guess you're iterating over all of the circles and testing for hits. How many circles are there? Are you doing something else?
For collision detection, it is not iterating over all the circles. This would be slower, I think, and also there would be no easy way to tell which circle is on top in the case when you would hit multiple circles. Everytime you fire, a "collision image" is drawn by painting just the circles (none of the explosions or ripple effets), each with a unique color based on their internal id number. Then using the mouse coordinates, I get the color of where you are aiming, and if that color is not black, you have hit a circle (whose color is also its internal id). Its very fast and perfectly accurate collision detection which will take less than the time it takes to draw the screen once to perform.
Only a couple other things occur when you shoot:
1) the cursor changes color
2) ripple effect is created (very cheap i doubt this is the problem)
3) PixelGrabber object is created (used in the collision detection process to grab the pixel color of a given pixel from the collision image).
4) if you hit, a explosion is created at that point; again very cheap process.
I am not creating a new image everytime you shoot; the old one is cleared and reused.