The only form of collision detection that I have used is to do with shapes, rather than the alpha value of pixels. Does anyone know an easy way to implement pixel collision detection?
CGRectIntersectsRect is good for rectangles, but I need to do far more complex shapes, thus why pixel detection and not just geometry based. Thanks for your reply
CGRectIntersectsRect is good for rectangles, but I need to do far more complex shapes, thus why pixel detection and not just geometry based. Thanks for your reply
CGRectIntersectsRect is good for rectangles, but I need to do far more complex shapes, thus why pixel detection and not just geometry based. Thanks for your reply
Cam
Your most likely better off doing some combination of multiple bounding circles/boxes instead of pixel perfect. Specially if you do any programmatic rotations or scaling.
The only form of collision detection that I have used is to do with shapes, rather than the alpha value of pixels. Does anyone know an easy way to implement pixel collision detection?
You could store a bitmask generated from your images at load time, choosing an arbitary alpha value to define as colliding. Then it's a simple matter of offsetting the two bit masks and looking to see if both have the pixel set.
Make sure you perform a cheaper form of intersection test first - i.e. a circular or bounding box test - because pixel/pixel comparisons are going to be slow.
And, to be honest, they're probably unneeded. What exactly are you trying to do collision on.
__________________
Visit Mr Jack Games for my blog and more about my games
I have attached a basic example of the kind of shapes that I will be colliding, and from it you can probably see why I need pixel detection. I doubt I would need to create a mask, as the image already contains the transparent pixels. My question: can anyone give me a basic way of detecting if the pixels in my image are transparent or not?
I have attached a basic example of the kind of shapes that I will be colliding, and from it you can probably see why I need pixel detection. I doubt I would need to create a mask, as the image already contains the transparent pixels. My question: can anyone give me a basic way of detecting if the pixels in my image are transparent or not?
Thanks,
Cam
Not sure this is the easiest way, but I would get an array with all the bitmap data then parse the alpha values to determine which pixel is transparent or not