-
Notifications
You must be signed in to change notification settings - Fork 0
Home
We need one. I think we should try and implement something that game entities can register with and then don't worry about anymore. Register yourself with the physics manager, give it a bit mask on what other things you collide with, and then provide a callback if a collision occurs.
this.game.physics.add(tank1, 0x05, myTankPhysicsCallback); //collides with objects of 0x01 and 0x04 only
this.game.physics.add(ball, 0x01, myBallPhysicsCallback); //collides with objects of 0x01 only
this.game.physics.add(wall, 0x04, null); //collides with objects of 0x04 only
And then in the physics manager update (called from game), it iterates over the list of objects, checking masks to see if they should collide with each other, and then actually checking for a collision if the masks match, then calling both objects callback methods to indicate they had a collision while passing the object they collide with.