Jump to content

Collide with left/right world bound only


Todi
 Share

Recommended Posts

Hi guys,

So, I want that my sprite just collide with left and right sides of the world bounds, and the top and bottom doesn't collide. What I did:

// setup ball
this._ball.anchor.set(0.5);
this._ball.body.bounce.set(1);
this._ball.body.collideWorldBounds = true;
this._ball.body.checkCollision.up = false;
this._ball.body.checkCollision.down = false;

But, even I disabling the up and down collision, it still colliding with up and down world bounds. What I have to do?

Thanks!

Link to comment
Share on other sites

4 hours ago, TickleMeElmo said:

I think there isn't really built in method like that, the checkCollision.up and down doesn't consider world bounds. one way is to just detect the collision yourself in the update func. For that method you could use Arcade checkWorldBounds and onWall 

Good tip! Thanks!

Link to comment
Share on other sites

15 hours ago, Todi said:

Hi guys,

So, I want that my sprite just collide with left and right sides of the world bounds, and the top and bottom doesn't collide. What I did:


// setup ball
this._ball.anchor.set(0.5);
this._ball.body.bounce.set(1);
this._ball.body.collideWorldBounds = true;
this._ball.body.checkCollision.up = false;
this._ball.body.checkCollision.down = false;

But, even I disabling the up and down collision, it still colliding with up and down world bounds. What I have to do?

Thanks!

An easier solution is to create custom bounds.

This is an example

http://phaser.io/examples/v2/p2-physics/collide-custom-bounds

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

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