Jump to content

Changing collision detection for arcade physics


warpig
 Share

Recommended Posts

Hi guys,

I've been digging through the code, examples and the forums and I'm yet to discover a solution to my problem.

I have an array of objects and have set their collision properties as follows:

this.physics.add.overlap(this.ball, this.bricks, this.hitBrick, null, this);

What I need is to be able to dynamically change the collision type to something like:

this.physics.add.collider(this.ball, this.bricks, this.hitBrick, null, this);

Is there any way I can achieve that?

Many thanks

Link to comment
Share on other sites

I've found the answer.  Changing the collider in update() resolves the problem:

    update()
    {      
        if(this.test === true)
        {
            this.physics.world.overlap(this.ball, this.bricks, this.hitBrick, null, this);
        }
        else
        {
            this.physics.world.collide(this.ball, this.bricks, this.hitBrick, null, this);
        }
    }

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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