Jump to content

How to define gamesize?


Faizy
 Share

Recommended Posts

Hey,

 

I want my game to be the size of the white area(as linked below) and the grey area should still be able to interact with the game(white area) via (Phaser-)buttons etc. meanwhile the gamestage/gamearea should only be on the white rectangular.

 

Is that possible? I´m looking for something to create "walls".

 

https://gyazo.com/81b7432d89f108a0b15c231e1ab6f4bc

 

Thank you

Link to comment
Share on other sites

I've done it. You end up offsetting the game world. There is an example somewhere 

 

In your create 

customBounds = { left: null, right: null, top: null, bottom: null };
createPreviewBounds(bounds.x, bounds.y, bounds.width, bounds.height);

 

function createPreviewBounds(x, y, w, h) {
    var sim = game.physics.p2;
    var mask = sim.boundsCollisionGroup.mask;
    customBounds.left = new p2.Body({ mass: 0, position: [ sim.pxmi(x), sim.pxmi(y) ], angle: 1.5707963267948966 });
    customBounds.left.addShape(new p2.Plane());
    customBounds.right = new p2.Body({ mass: 0, position: [ sim.pxmi(x + w), sim.pxmi(y) ], angle: -1.5707963267948966 });
    customBounds.right.addShape(new p2.Plane());
    customBounds.top = new p2.Body({ mass: 0, position: [ sim.pxmi(x), sim.pxmi(y) ], angle: -3.141592653589793 });
    customBounds.top.addShape(new p2.Plane());
    customBounds.bottom = new p2.Body({ mass: 0, position: [ sim.pxmi(x), sim.pxmi(y + h) ] });
    customBounds.bottom.addShape(new p2.Plane());
    sim.world.addBody(customBounds.left);
    sim.world.addBody(customBounds.right);
    sim.world.addBody(customBounds.top);
    sim.world.addBody(customBounds.bottom);
}

 

The top area is referenced via negative coords.

 

If that is too hard, you can make the world too big for the screen and then in your update use the camera position to determine where the fixed areas display on teh screen

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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