Jump to content

Collide problem in P2 Physics


Recommended Posts


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.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.damping = 0.7;

I also added the images. Thanks in advance.



Edited by Ajora
unnecessary tags are deleted
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...