Jump to content

collision does not work


dandorf
 Share

Recommended Posts

I have made ​​several crashes my game, and now I have intenado create another, and not working. And I've done the same way as the above ... I have this in the CREATE function:

barras = game.add.group();				barraLateral = barras.create(0, 10, 'barra');		barraLateral2 = barras.create(0, 460, 'barra');					game.physics.arcade.enable(barras);				barras.enableBody = true;			barraLateral.body.immovable = true;		barraLateral2.body.immovable = true;                game.physics.arcade.enable(playerBet);                 playerBet.body.enable = true;                 playerBet.anchor.setTo(0.5, 0.5);                 playerBet.body.collideWorldBounds = true;                 playerBet.body.bounce.setTo(0, 0);                 playerBet.body.immovable = true;

and the update function

game.physics.arcade.collide(barras, playerBet);

The collision does not work ...

Link to comment
Share on other sites

Arcade is started by default, and it is also the default system enabled when you enableBody = true on a group, so this should work as intended. I would swap the playerBet and barras parameters around in the collide function but I don't think it would make that much of a difference.

 

The real problem is almost certainly that playerBet.body.immovable is true - immovable bodies do not register collisions, so if you're moving your player object around it will not affect the objects it's hitting. Instead try playerBet.body.moves = false, which allows the object to collide, but stops the physics system influencing its position, which effectively stops it being pushed around by other objects.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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