MichaelD Posted July 12, 2014 Share Posted July 12, 2014 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: 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 More sharing options...
Max Posted July 12, 2014 Share Posted July 12, 2014 I'm no expert, but you can define collision polygons with P2. Check out this example: http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=load+polygon+2.js&t=load%20polygon%202 Link to comment Share on other sites More sharing options...
MichaelD Posted July 13, 2014 Author Share Posted July 13, 2014 So I should declare a polygon as a shape? Or is there a way for P2 to auto detect the shape and discard the transparent pixels? Link to comment Share on other sites More sharing options...
Max Posted July 14, 2014 Share Posted July 14, 2014 I'm not sure, I've never used P2 before. Maybe someone else knows. Link to comment Share on other sites More sharing options...
Fishrock123 Posted July 14, 2014 Share Posted July 14, 2014 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 More sharing options...
Recommended Posts