proyb2 Posted July 19, 2015 Share Posted July 19, 2015 I wish to capture more that one "person" sprites using the arcade overlap method but could only return the latest sprite which is "person3" instead of "person0", "person1", "person2", "person3"? How do I capture all?for(var i=0;i<4;i++){person = game.add.sprite(500, 140+(i*20), 'pSprite');person.name="person"+iperson.enableBody = true;person.physicsBodyType = Phaser.Physics.ARCADE;game.physics.enable(person, Phaser.Physics.ARCADE);}robot = game.add.sprite(520, 200, 'robot');robot.enableBody = true;game.physics.enable(robot, Phaser.Physics.ARCADE);setTimeout(function(){game.physics.arcade.overlap(robot, person, HitsButton, null, this);}, 3000);function HitsButton(a,{console.log("hits",b.name)} Link to comment Share on other sites More sharing options...
substandardgaussian Posted July 20, 2015 Share Posted July 20, 2015 Put all your people in a group and check for overlap against the group. Arcade will walk the group and test for overlap on all of them separately. Link to comment Share on other sites More sharing options...
proyb2 Posted July 20, 2015 Author Share Posted July 20, 2015 Put all your people in a group and check for overlap against the group. Arcade will walk the group and test for overlap on all of them separately. Put sprites and images into a group, that's really works! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts