Jump to content

setCollisionGroup() and world bounds


Recommended Posts

Hi, I'm started develop my first Phaser game 2 weeks ago and I'm using Phaser CE.

In my game there is a monster and lots of players with P2 physics. When monster kill a player, I make killed player's alpha = 0.1 and set new collision group e.g., setCollisionGroup(deadCollisionGroup) for no collide with alive players. But dead player isn't collide with world bounds. My simplified code:

// p2 physics
game.physics.p2.restitution = .4;

var players = game.add.group();
players.enableBody = true;
players.physicsBodyType = Phaser.Physics.P2JS;

// collision groups
var playerCollisionGroup = game.physics.p2.createCollisionGroup()
var deadCollisionGroup = game.physics.p2.createCollisionGroup()

var player = players.create(0, 0, 'sprite');
player.body.setCollisionGroup(playerCollisionGroup); // initial collision group

// when player dies in action

There is a lot of definition about collisions and world bounds in Pahser CE documentation. I'm confused about that. How should I do that?

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...