User collision

I was recently assigned to create a game using the Corona SDK. The main pillar of the game will be a simple event: the user must put the ball in the basket, and I must be able to handle this event.

Here is an image for better understanding:

enter image description here

I managed to create a collision form for the basket, but I had problems with the collision inside this basket. My first thought was as follows:

  • create a new form
  • and place it according to the โ€œbellyโ€ of this basket.
  • Add it to the world of physics and listen for a collision.

With a hybrid drawing, it looks like this:

enter image description here

But there is a problem: if I add this form to physics, it will not allow the ball to get into the basket, it will process this form as a solid object.

So my question is : how can I make this custom object collide without blocking the ball will fall through it? I read a lot of forum posts with similar questions, but none of them got the correct answer. There must be a way to do this in an elegant way.

And one note: Please do not offer collision checking manually, with the intersection of the rectangles , because in this simple case it will work, but later I may need to change the shape of the basket, and then it will be useless!

+4
source share
1 answer

Box2D has a thing called a "sensor."

You just found that the internal collision is a sensor, and it will do exactly what you want :)

Just do:

MyInternalCollisionObject.isSensor = true 
+5
source

Source: https://habr.com/ru/post/1439500/


All Articles