Uhfgood Posted August 18, 2014 Share Posted August 18, 2014 I have 4 groups that I want to test my bullet group against. What I noticed when it was passed a group, the callback only passes in the actual sprite that was collided. I would like to know if it's the same way if I specified an array of groups -- this is the form I want to usegame.physics.arcade.overlap( bullets, [asteroidGroup1, asteroidGroup2, asteroidGroup3, asteroidGroup4], bulletAsteroidCollisionHandler, null, this );then something likefunction bulletAsteroidCollisionHandler( bullet, asteroid1, asteroid2, asteroid3, asteroid4 ){ // ...}Will this work, and is this correct? Link to comment Share on other sites More sharing options...
wayfinder Posted August 19, 2014 Share Posted August 19, 2014 The collision callback will be executed separately for each colliding object. So there will only ever be the one parameter. Link to comment Share on other sites More sharing options...
Uhfgood Posted August 19, 2014 Author Share Posted August 19, 2014 What you're saying is it's only passing through the array of objects. I still want to know how to use it properly. Do I iterate through it to get the desired object (for instance 'for( var i = 0; i < 4; i++ ) { var object = objectArray[ i ]; }' ? Also if it is a group, does that mean a single sprite is passed to the callback (so it would be 4 single sprites in an array passed to the callback?) Link to comment Share on other sites More sharing options...
wayfinder Posted August 19, 2014 Share Posted August 19, 2014 The collision is being broken up into separate, distinct collision events, each with two participants. There's no "full picture" callback, but your callback will be executed for each separate collision, and will have the participating objects of that particular isolated event available. Link to comment Share on other sites More sharing options...
Recommended Posts