Overlaping detection of 2 not squared objects

Hi! I’m not sure if the tittle explains the problem wich I’m stuck, but I’ll try to explain a bit further.

In this project I want to have a hand-made listener (checking the conditions every enterFrame) so that I get when an object gets out of a moving street.

The street consists of several parts in a continually moving loop. Due to the high number of worlds, I would discard, if possible, the use of physics, as I’d have to create manually and not accurate the shape of each body (every part of the street).

The first solution I thought about is creating masks of each street part, and “shaping” the object with 5 strategical points relative to the object. In each frame I’d fake a touch event that should be triggered in the isHitTestMasked object listener wich would stop further events of the background. In case the background listener gets triggered there’s a part of the object out of the street.
Although all listeners, masks and points are already working I have no clue how to fake that event not calling to the listener by myself. Edit: (dispatchEvent triggers the listener even if the ev.x and ev.y are out of the Masked area)

The other option that comes to my mind by now is getting the information of the pixel of each point of the object using a bitmap of the street mask, even though I haven’t found too reliable information about bitmasking in Corona and I’m afraid there’s no way to use this feature.

I’m sorry for a question so especifical as this one, but I think it resumes some other problems I had before and I’m sure it would be really helpfull for other developers with similar issues.

Thanks in advantage!

Hi @JJA,

The ultimate solution is your choice, but I can direct you to some resources on these topics:

http://www.coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

http://docs.coronalabs.com/guide/media/imageMask/index.html

Hope this helps somewhat,

Brent Sorrentino

Thanks for the answer Brent!

Finally, due to the hight number of levels and that all the shapes are completely irregular and there’s no way to automatize the creation of circles of rectangles, I invested my time in creating a lua bitmap reader of my mask, so every frame I check if there’s is a black pixel in all the strategical coordinates of the object. It’s worth saying to someone with the same issue that having a bitmap table of 1024x768 pixels crashes corona, so I have a smaller bitmap mask (128x76) and I translate the coordinates to the 8x smaller table to get the color of the pixel.

If someone is interested in the bitmap reader, this class helped me a lot and it’s properly working

https://bitbucket.org/itraykov/agen-utils/src/64341c10f23f/bmp.lua

Have you seen this: http://developer.coronalabs.com/code/polygon-intersection

Hi @JJA,

The ultimate solution is your choice, but I can direct you to some resources on these topics:

http://www.coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

http://docs.coronalabs.com/guide/media/imageMask/index.html

Hope this helps somewhat,

Brent Sorrentino

Thanks for the answer Brent!

Finally, due to the hight number of levels and that all the shapes are completely irregular and there’s no way to automatize the creation of circles of rectangles, I invested my time in creating a lua bitmap reader of my mask, so every frame I check if there’s is a black pixel in all the strategical coordinates of the object. It’s worth saying to someone with the same issue that having a bitmap table of 1024x768 pixels crashes corona, so I have a smaller bitmap mask (128x76) and I translate the coordinates to the 8x smaller table to get the color of the pixel.

If someone is interested in the bitmap reader, this class helped me a lot and it’s properly working

https://bitbucket.org/itraykov/agen-utils/src/64341c10f23f/bmp.lua

Have you seen this: http://developer.coronalabs.com/code/polygon-intersection