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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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