Collision detection only on stroke

Is it possible to detect a collision only on the stroke of a circle?

I have a circle that is gradually increasing in size and would like to check if it collides with other circles. But I would like to check only if the outline not the fill of the circle collides with another circle.

Is this possible?

Hi @mail084,

This functionality may be better accomplished using non-physics collision detection, for two specific reasons:

  1. Box2D physics doesn’t make “doughnut”-shaped bodies easy (bodies with empty interior “holes”)… you’d need to construct the body from several parts to mimic the overall shape, and even then, it wouldn’t be perfect.

  2. Box2D doesn’t play nicely with expanding/scaling objects, so you’d need to re-create the body constantly.

Here’s a tutorial on non-physics collision detection which should help you get started:

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

Best regards,

Brent

Thank you very much for your reply Brent!

I guess I will go with that then.

One more question. When I scale a small circle up by factor 50 for example I can see that the straight lines that made the circle plus a 40px circle doesn’t look crisp at all on a retina iPhone. Is there a way around that without using pngs? 

hey mail084, 

You could start with a large, high-res display.newcircle, and scale it down before you need to display it, then scale it back up as needed.

Hi @mail084,

This functionality may be better accomplished using non-physics collision detection, for two specific reasons:

  1. Box2D physics doesn’t make “doughnut”-shaped bodies easy (bodies with empty interior “holes”)… you’d need to construct the body from several parts to mimic the overall shape, and even then, it wouldn’t be perfect.

  2. Box2D doesn’t play nicely with expanding/scaling objects, so you’d need to re-create the body constantly.

Here’s a tutorial on non-physics collision detection which should help you get started:

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

Best regards,

Brent

Thank you very much for your reply Brent!

I guess I will go with that then.

One more question. When I scale a small circle up by factor 50 for example I can see that the straight lines that made the circle plus a 40px circle doesn’t look crisp at all on a retina iPhone. Is there a way around that without using pngs? 

hey mail084, 

You could start with a large, high-res display.newcircle, and scale it down before you need to display it, then scale it back up as needed.