Jump to content

P2 collisions refuse to cooperate


Local_Minimum
 Share

Recommended Posts

I'm very new to Phaser (<1 week) but I've stared at the examples and I think it really looks as if I'm doing the right thing, yet collisions refuse to work.

 

In my gameState.create I run the following to set up my P2-physics:

     game.physics.startSystem(Phaser.Physics.P2JS);       game.physics.p2.setImpactEvents(true);      game.physics.p2.restitution = 0.8;      game.world.setBounds(-90, -300, 8200, 20000);      this.playerCG = game.physics.p2.createCollisionGroup();     this.enemiesCG = game.physics.p2.createCollisionGroup();     this.groundCG = game.physics.p2.createCollisionGroup();      game.physics.p2.updateBoundsCollisionGroup();

and later adding the player:

     this.player =         game.add.existing(             new Player(this, game, 750, 180, 0));     game.physics.p2.enable(this.player);     this.player.body.setCollisionGroup(this.playerCG);     this.player.body.collides(this.groundCG, this.player.collidesGround, this);     this.player.body.collides(this.enemiesCG);    

my grounds are the 'fistulaeHair' and are added:

         game.physics.p2.enable(fistulaHair);          fistulaHair.body.kinematic = true;          this.ground.add(fistulaHair);          fistulaHair.body.setCollisionGroup(this.groundCG); 

I'm expecting this.player.collidesGround to be called when flying into the ground but nothing happens:

 

post-8448-0-70783800-1398986975_thumb.pn

 

It doesn't collide the the collidesGround has a console.log as first line which never fires.

 

I must be missing something very basic it feels like.

 

Also, as a side question, how do I test if I hit the world-end in P2-physics?

 

Any help much appreciated.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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