DrawableRectangle

Extends: Drawable

Draws a rectangle, filled and/or outlined.

The rectangle's top left corner sits at the drawable's own world position (its offset transformed by the owning entity), extending width to the right and height downwards on screen - the same anchoring an Image uses, so the two are interchangeable.

In the direct (billboard) draw modes - which is what a 2D game gets, since a Camera2d resolves matchCamera to directToCamera - this is a plain axis-aligned rectangle. In the oriented/solid/wireFrame draw modes it becomes a quad that rotates and foreshortens in 3D like any other billboard (see examples/3d's RectanglesRoom).

Set color for the fill and outlineRGBA for the outline (both packed RGB, no alpha byte - alpha is separate). Leaving outlineRGBA unset means no outline at all; set filled = false for an outline-only rectangle.

Properties

  • filled (boolean) — Whether the rectangle's interior is filled with color. Set false for an outline-only ' rectangle, which needs outlineRGBA set too or nothing is drawn at all.

Constructor

new DrawableRectangle( owner: GameEntity, width: float, height: float, args?: roAssociativeArray, ): DrawableRectangle

Parameters

  • owner (GameEntity)
  • width (float)
  • height (float)
  • args (roAssociativeArray, optional, default: "{}")

Instance Methods

setSize(width: float, height: float): void

Resizes the rectangle. Use this rather than assigning to the inherited width/height, which are deliberately not public - a resize isn't movement, so it has to tell the renderer to recompute this drawable's geometry (see Drawable.invalidateGeometry).

Parameters

  • width (float) — new width in world units
  • height (float) — new height in world units

Returns

  • void

addToScene(rendererObj: Renderer): BGE.SceneObject

Parameters

Returns