Constructor
new Box(left, up, right, down)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
left |
boolean | true | Default visibility of the left wall. |
up |
boolean | true | Default visibility of the top wall. |
right |
boolean | true | Default visibility of the right wall. |
down |
boolean | true | Default visibility of the bottom wall. |
Members
(static, readonly) WALLS :string
Valid walls to use for Box#toggleWall
and Box#toggleOpposite
methods.
Type:
- string
Properties:
Name | Type | Description |
---|---|---|
LEFT |
string | String value for the left wall. |
UP |
string | String value for the top wall. |
RIGHT |
string | String value for the right wall. |
DOWN |
string | String value for the bottom wall. |
down
Properties:
Name | Type | Description |
---|---|---|
down |
boolean | Bottom-side wall of the box. |
left
Properties:
Name | Type | Description |
---|---|---|
left |
boolean | Left-side wall of the box. |
right
Properties:
Name | Type | Description |
---|---|---|
right |
boolean | Right-side wall of the box. |
up
Properties:
Name | Type | Description |
---|---|---|
up |
boolean | Top-side wall of the box. |
Methods
setWalls(enable)
Sets all of the walls either on or off.
Parameters:
Name | Type | Description |
---|---|---|
enable |
boolean | To toggle on or off. |
toggleOpposite(wall, enable)
Wrapper method to change the visibility of the opposite Wall
in the box based off of a string.
Felt much easier to just use a switch statement here rather than reuse Box.toggleWall
.
Parameters:
Name | Type | Description |
---|---|---|
wall |
Box.WALLS | What wall that will be the opposite of the toggled wall. |
enable |
boolean | To toggle on or off. |
Example
Box.toggleOpposite('LEFT', true) // Toggles the right wall on.
toggleWall(wall, enable)
Wrapper method to change the visibility of a given Wall
in the box based off of a string.
Parameters:
Name | Type | Description |
---|---|---|
wall |
Box.WALLS | What wall to toggle. |
enable |
boolean | To toggle on or off. |