I am animating a sprite on a pixel grid. I have several options, with pros and cons for each. I have pretty much experience with javascript (six years), but I don't have this type of thing. The problem is that I donโt know how expensive each option will be.
The sprite should be rendering fairly quickly and be inexpensive enough to have at least five starts at the same time when the collision detection starts.
Ideally, I would like to use a grid of elements inside the shell, displaying color and alpha channels for each element from a multidimensional array. The main professional here is that I can run pixel-pixel collision detection and go through the transparent parts of the sprite. With any image-based sprite, the onClick event will fire even if I click on a transparent pixel (I will have to work hard to pass clicks through transparent pixels, and this can be quite expensive).
The next option is to use css sprites. css-tricks.com/css-sprites/ That would be easy peasy, but as mentioned earlier, onClicks would not go through the transparent pixels. I can probably force it, but then again, it can be expensive, and it will take a long time to implement.
Another option is animated gifs, but they are huge, limited in color and difficult to control animations. I would rather not go there.
And then there is the html5 canvas element that I donโt really know about, and would like to avoid, if at all possible. I donโt know how any of my code will work even with the canvas element, and I doubt that it will do what I want in the long run.
So what is better for performance? Will the first (and most preferred) viable option? Or am I missing something?
source share