Changing collision point in an image?

Hi,

Is it possible to change the collision point in an image?

To understand what I mean look at this picture:

http://i40.tinypic.com/2isgrv6.png

The lower box is dragged in to one of the boxes above, and the collisions are detected, however when I switch box to another box the collision event is triggered again, and I understand why, but it causes problem in my program as I have some logic in both the “began” and “ended” phase and now the program trigger those phases several time without me having any real control over it.

Therefore I wonder if it’s possible to set object.x as the “collision point” so only when object.x collides with anyone of the boxes above the collision event will be triggered?

Best regards,

Tomas

Hi Tomas,

If I understand your goal, you want to have just the red “dot” be the collision point. By default, a physics body is drawn to trace around the entire image size, as a rectangle/square. But since you want to make the body smaller (just the tiny dot in the middle), you can do it one of two ways:

  1. Draw a custom polygon body using corner points, inset from the actual image.

  2. Make the physics body circular, and make its radius much smaller than the image size.

Both of these methods are covered in the physics guides.

http://developer.coronalabs.com/content/game-edition-physics-bodies

Best regards,

Brent

Hi Tomas,

If I understand your goal, you want to have just the red “dot” be the collision point. By default, a physics body is drawn to trace around the entire image size, as a rectangle/square. But since you want to make the body smaller (just the tiny dot in the middle), you can do it one of two ways:

  1. Draw a custom polygon body using corner points, inset from the actual image.

  2. Make the physics body circular, and make its radius much smaller than the image size.

Both of these methods are covered in the physics guides.

http://developer.coronalabs.com/content/game-edition-physics-bodies

Best regards,

Brent