ForgeableSum Posted December 21, 2014 Share Posted December 21, 2014 It's easy to set collide between two sprites you know the names of. But how does one set collide to all sprites in a group (with each other)? In other words, the parameters aren't sprite1 colliding with sprite 2 but every sprite in a group colliding with every sprite in the same group. I'm sure I could accomplish this with a nested foreach loop, but I'm looking for something less dirty. Link to comment Share on other sites More sharing options...
lewster32 Posted December 22, 2014 Share Posted December 22, 2014 Just pass the single group to the collide function:game.physics.arcade.collide(group);As seen in this example: http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=group+vs+self.js&t=group%20vs%20self Link to comment Share on other sites More sharing options...
P4nch0 Posted May 7, 2016 Share Posted May 7, 2016 Hi, I have a problem with collide in one group. Create group: this.animal = this.game.add.physicsGroup(); this.game.physics.arcade.enable(this.animal); this.animal.enableBody = true; Adding animals to the group: this.sheep =this.animal.create(zwierzex, zwierzey, 'sheepwalk'); Collision: this.game.physics.arcade.collide(this.player, this.blockedLayer); this.game.physics.arcade.collide(this.player, this.animal); this.game.physics.arcade.collide(this.animal); this.game.physics.arcade.collide(this.animal, this.blockedLayer, this.stopanimzwierz, null, this); There are colliding wiht everything else but not with each other in the same group.. anuone know why? Please help VitaZheltyakov 1 Link to comment Share on other sites More sharing options...
Recommended Posts