Jump to content

Collision detection with transparent pixels


MichaelD
 Share

Recommended Posts

Hello,

 

I was wondering how could I implement collision detection and not when one of the sprites/images has transparent pixels (and these should not trigger overlap/collide). Consider the following image:

 

oktoGFX_5_zpsf63da3f5.png

 

So that should only trigger the overlap/collide when the ball touches the part of the oktagon where there is no transparency. Is this possible with Phaser and I would really appreciate an example or snipper or anything you can share.

 

Thanks.

Link to comment
Share on other sites

No collision detects pixels. It detects shapes.

You can make it via p2 by making a hollow (concave) octagon that is missing a side; internally it will be split up into convex shapes.

See: https://github.com/photonstorm/phaser/blob/master/src/physics/p2/Body.js#L935-L996

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...