Todi

Collide with left/right world bound only

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!

Share this post


Link to post
Share on other sites

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 

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.