I used wallclocktime and it worked perfectly
What I'm trying to achieve is a destructible terrain "à la Worms", which counts how much pixels were destroyed in order to generate a proper number of particles.
I first used a loop using "Canvas.alphaAt(X,Y)" for each pixel contained in the radius of the explosion, but r0j0hound suggested that I could store all the Canvas pixels in an array, and iterate over the array because it would be faster.
That's what I did and it is indeed faster. I first look at all the pixels contained in the explosion radius. For each pixel, I look at its transparency. If its alpha ≠ 0, then I increases the particle quantity variable then I update my array to replace this pixel with a transparent one.
So this is this step which is slow, but I don't see how I could optimize this, I need to update all these specific pixels in the array, because I compare my collisions with the pixels contained in the array, not with the pixels currently drawn in my canvas (because it's slower).
I made a thread about this project :
The elements have to be updated at once, because in my final game, more than 2 projectiles could hit the landscape quickly in the same area.
chrisinfinger > Because I only update pixels that were not transparent, I think it already works as a filter, sort of. Am I right ?