Skip to content

Latest commit

 

History

History
99 lines (60 loc) · 2.07 KB

File metadata and controls

99 lines (60 loc) · 2.07 KB

Box

A box that can be rendered on screen.


Constructor

new Box(scene, config);

Arguments

  • sceneScene The scene this Object is a part of.
  • configObject The Box's config object.
    • config.xnumber This Box object's x-coordinate.
    • config.ynumber This Box object's y-coordinate.
    • config.widthnumber This Box object's width.
    • config.heightnumber This Box object's height.
    • config.colorstring Optional Box color.
    • config.backgroundColorstring Optional background color.
    • config.stylestring The box line style. "line" || "double"

Methods

get width()

Get the rounded width of the box.

set width(n)

Set the width of the box.

Arguments

  • nnumber The new width of the box.

Throws

  • Error If the width value is not of type 'number'.

get height()

Get the rounded height of the box.

set height(n)

Set the height of the box.

Arguments

  • nnumber The new height of the box.

Throws

  • Error If the height value is not of type 'number'.

get renderable()

Generate the renderable representation of the box.

Returns

  • PixelMesh The PixelMesh representation of the box based on its dimensions, color, and style.

Static Methods

asPixelMesh(width, height, color, backgroundColor, style)

Get just the renderable PixelMesh portion of a Box instance.

Parameters

  • widthnumber This Box object's width.
  • heightnumber This Box object's height.
  • colorstring Option Box color.
  • backgroundColorstring Optional background color.
  • stylestring The box line style. "line" || "double"

Returns

The generated PixelMesh.

Example

const myGameObject = new GameObject(scene, 0, 0, "system");

myGameObject.renderable = Box.asPixelMesh(
	width,
	height,
	color,
	backgroundColor,
	style
);