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

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