I need to be able to do per-pixel touch detection on a Sprite.
The example using TouchDispatch protocol uses a rect-based system, which works good for rectangle-based sprites, but not for ones which aren't square.
For example, I have a bunch of PNG files with triangles in them, against a transparent background. If I draw them as sprites, and tile them so that they are edge to edge (flipping every even triangle), then there will be triangles who can't be tapped, if we use a rect-based criteria.
The old-school way of doing it in 8-bit days was to do a bitmask, so you would pregenerate an array of ints, say, from a sprite, so that you could just inspect that array for the corresponding value for that pixel. So pixels with your transparent color (purple) would be assigned a value of 0, and any other value would be assigned a value of 1. Then, just ask the array for the value that corresponds to your X * Y of the click coordinates, and return YES or NO when asked if that coord represents a hit.
I could probably do the same thing using Cocos, but it seems like a kludge given the sophistication of the library. Does anybody know if there is an easier way using Cocos?