Jump to content

confusion after changing Arcade physic to P2


Recommended Posts

so i just started using phaser for test

i've followed the tutorial in the phaser website  (making-your-first-phaser-game) everything is clear no problem .


but since i've making a pool game i need rotation on collision so i've switched to P2 ... suddenly everything moves and collides!

here is the live code



i have 2 groups

sides ( sides of table ) and  balls


1 - i want sides to be immovable so i 've added

side.body.immovable = true;

to each object like in arcade ... it doesnt work ... how can i make objects immovable in p2 ?

        game.physics.startSystem(Phaser.Physics.P2JS);        sides = game.add.physicsGroup(Phaser.Physics.P2JS);        side = sides.create(0,0 , 'sideA');        side.body.immovable = true;

2 - i dont want my player to collide with red balls ... he should only be able to collide with white ball

so in arcade we had to define each collision , if not  they wouldn't collide

game.physics.arcade.collide(player , wball ); 

but here there is no defining everything collides with everything !

how can i make exception in on cllision so my player wouldn't collides with anything other then white ball (Wball) ?




3 - what happend to overlap ? or collide call back functions ? i need to add some holes to my table and make the balls disappear
 on overlap .. also i need to reset my player position on collide with the white ball ... in the arcade i had it like this

game.physics.arcade.overlap( balls , holes ,  killBall  , null, this);    function killBall  ( b , h  ){ b.kill() ; }











Link to comment
Share on other sites


  • Recently Browsing   0 members

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