MoreK Posted November 1, 2015 Share Posted November 1, 2015 Is there a way to set a callback when sprite is colliding with world bounds, when using P2 physics? I need to trigger a sound effect when a ball drops down and hits the world bottom. sprite.body.createBodyCallback does the trick with other sprites, but I couldn't find anything about world bounds. I can create an extra block below the world bound, that would do the trick, but I thought there may be a more sophisticated way to implement this. Link to comment Share on other sites More sharing options...
icp Posted November 1, 2015 Share Posted November 1, 2015 Yes, you can use this http://phaser.io/docs/2.4.4/Phaser.Physics.P2.html#setBoundsalongside with http://phaser.io/docs/2.4.4/Phaser.Physics.P2.html#boundsCollidesWithandhttp://phaser.io/docs/2.4.4/Phaser.Physics.P2.html#boundsCollisionGroup . Link to comment Share on other sites More sharing options...
MoreK Posted November 2, 2015 Author Share Posted November 2, 2015 Thanks! I assume that after all this you create a callback with createGroupCallback? Sounds a bit complicated compared to sprite-to-sprite collision callbacks but I'll give it a try.... Link to comment Share on other sites More sharing options...
icp Posted November 2, 2015 Share Posted November 2, 2015 Yes, but personally I would simply create 4 bodies, less headache. Link to comment Share on other sites More sharing options...
Recommended Posts