Physics.P2#setBounds()

setBounds(x, y, width, height, left, right, top, bottom, setCollisionGroup)

Sets the bounds of the Physics world to match the given world pixel dimensions.
You can optionally set which 'walls' to create: left, right, top or bottom.
If none of the walls are given it will default to use the walls settings it had previously.
I.e. if you previously told it to not have the left or right walls, and you then adjust the world size
the newly created bounds will also not have the left and right walls.
Explicitly state them in the parameters to override this.

Parameters
Name Type Argument Default Description
x number

The x coordinate of the top-left corner of the bounds.

y number

The y coordinate of the top-left corner of the bounds.

width number

The width of the bounds.

height number

The height of the bounds.

left boolean <optional>
true

If true will create the left bounds wall.

right boolean <optional>
true

If true will create the right bounds wall.

top boolean <optional>
true

If true will create the top bounds wall.

bottom boolean <optional>
true

If true will create the bottom bounds wall.

setCollisionGroup boolean <optional>
true

If true the Bounds will be set to use its own Collision Group.

Source code: physics/p2/World.js (Line 646)
doc_phaser
2017-02-14 11:01:30
Comments
Leave a Comment

Please login to continue.