Pixel Perfect Collision Detection

I followed another topic, implemented it and found/fixed bug there.
It could be that this topic has the same bug.
Working version is here: Pixel collision detection for v3.x
–Josef

My helper class is not written for this kind of collission detection.

You could test each bit but it would be an N time operation or N^2 at worst. If I were writing your game, I’d use some kind of heuristic. Off the top of my head, I would preprocess the ship images and keep track of the maximal bounds of the ship. Say, keep track of the first pixel x value for any given y value from and left and from the right and compare. Basically some sort of approximation that runs much faster

Maybe break the sprites conceptually into primitive shapes that you can mathematically check intersection on quickly

OK thanks for all your support.

I’ll try it.

This doesn’t work if the Sprites are child nodes of different sprites.

Does anyone else have this problem ? It seems to me because r1.intersects(r2) in PixelCollision::collidesWithSprite(Sprite *sprite1, Sprite *sprite2, bool pp) sometimes returns false.

This must be obvious to the rest of you, but have I misunderstood something about how bounding boxes work ? Or is this a bug ?

I am using 3.13.1

Check this out:

@piotrros - Isn’t that a different issue ?

I’ve never used collidesWithSprite method - it doesn’t even seem to be in the code. Where did you get it and how is it implemented?

Hmmm I seem to have posted in the wrong thread! The source is: