From the course: HTML5 Game Development with Phaser

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Group-versus-group collisions

Group-versus-group collisions

From the course: HTML5 Game Development with Phaser

Start my 1-month free trial

Group-versus-group collisions

Unfortunately we do have to react to the inevitable collision between our bunny entities and the onslaught of space rocks. We will once again test collisions against the two entity groups, using Phasers Update method. So inside of GameJs, let's scroll back down to our Update method. And we can actually copy and paste, this Overlap method right here, and simply change some parameters, so that we target the bunnies instead of the burst. So here we have this Physics Arcade overlap and we still want to test against Space Rock group for the first parameter. But for the second, we actually want to test against the Bunny group. So this.bunnygroup. Instead of burstCollision, we're going to create a new function here called bunnyCollision. So we'll put that in here. This parameter stays null. And we once again pass through the current context which is our Space Rock group and our Bunny group and the objects that have been particularly overlapped within those groups so that we can react to…

Contents