Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Collide Only With Left Or Right Bounds


oliversb
 Share

Recommended Posts

How do I get the body to only collide with left or right bounds? I am using arcade physics and tried to convert this over with from a post using a different physics system.

'function createPreviewBounds(x, y, w, h) {
    var sim = game.physics.arcade;
    
    customBounds.left = new Phaser.Body({ mass: 0, position: [ x, y ], angle: 1.5707963267948966 });
    customBounds.left.addShape(new Plane());
    
    customBounds.right = new Phaser.Body({ mass: 0, position: [ x + w, y ], angle: -1.5707963267948966 });
    customBounds.right.addShape(new Phaser.Plane());
    // customBounds.right.shapes[0].collisionGroup = mask;

    customBounds.top = new Phaser.Body({ mass: 0, position: [ x, y ], angle: -3.141592653589793 });
    customBounds.top.addShape(new Phaser.Plane());
    // customBounds.top.shapes[0].collisionGroup = mask;

    customBounds.bottom = new Phaser.Body({ mass: 0, position: [ x, y + h ] });
    customBounds.bottom.addShape(new Phaser.Plane());
    // customBounds.bottom.shapes[0].collisionGroup = mask;
    
    sim.world.addBody(customBounds.left);
    sim.world.addBody(customBounds.right);
    sim.world.addBody(customBounds.top);
    sim.world.addBody(customBounds.bottom);
}'
 

I wrote this code were I wanted to createPreviewBounds

'//create bounds
    var bounds = new Phaser.Rectangle(100, 100, 400, 400);
    customBounds = { left: null, right: null, top: null, bottom: null };
    
    createPreviewBounds(bounds.x, bounds.y, bounds.width, bounds.height);'

I cannot seem to find the right constructor.

Thanks

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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