Jump to content

Collide problem in P2 Physics


Ajora
 Share

Recommended Posts

Hello,

I am making a simple haxball clone and I have a problem. I have a player and a ball on the field, and there are field lines on top, left, right and bottom.

When player hits the ball, the ball sometimes goes out of the lines (it goes the other side when it should hit the line and come back). It generally happens when the ball goes fast. I thought it is a bug but I probably miss something because I am newbie on Phaser.

This is how I implemented a line:

this.topLine = this.add.sprite(400, 40, 'line');
this.topLine.scale.setTo(760, 2);
this.physics.p2.enable(this.topLine);
this.topLine.body.static = true;

And here is the ball implementation:

this.ball = this.add.sprite(400, 250, 'ball');
this.physics.p2.enable(this.ball, true);
this.ball.body.setCircle(10);
this.ball.body.damping = 0.7;

I also added the images. Thanks in advance.

1.png

2.png

Edited by Ajora
unnecessary tags are deleted
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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