Canvas

Contains a roku roBitmap which all game objects get drawn to.

Properties

  • bitmap (ifDraw2D) — bitmap GameEntity images get drawn to
  • offset (BGE.Math.Vector) — Position offset from screen coordinates (z value ignored)
  • scale (BGE.Math.Vector) — Scale (z value ignored)
  • renderer (Renderer) — Renderer for this canvas
  • rendererOptions (RendererOptions)

Constructor

new Canvas( gameEngine: Game, canvasWidth: integer, canvasHeight: integer, options?: RendererOptions, ): Canvas

Creates a Canvas object and bitmap

Parameters

  • gameEngine (Game)
  • canvasWidth (integer) — width of canvas
  • canvasHeight (integer) — height of canvas
  • options (RendererOptions, optional, default: "{useBitmapPooling: true}")

Instance Methods

setSize(canvasWidth: integer, canvasHeight: integer): void

Changes the size of the canvas

Parameters

  • canvasWidth (integer) — width of canvas
  • canvasHeight (integer) — height of canvas

Returns

  • void

setBitmap(bitmap: ifDraw2D): void

Parameters

  • bitmap (ifDraw2D)

Returns

  • void

clear(color: integer): void

Clears the canvas to the given background color

Parameters

  • color (integer)

Returns

  • void

getOffset(): BGE.Math.Vector

Gets the offset of the canvas from the screen

Returns

  • BGE.Math.Vector

getScale(): BGE.Math.Vector

Gets the scale of the canvas

Returns

  • BGE.Math.Vector

setOffset(x: float, y: float): void

Sets the offset of the canvas. This is as Float to allow incrementing by less than 1 pixel, it is converted to integer internally

Parameters

  • x (float) — x offset
  • y (float) — y offset

Returns

  • void

setScale(scale_x: float, scale_y?: float): void

Sets the scale of the canvas

Parameters

  • scale_x (float) — horizontal scale
  • scale_y (float, optional, default: "invalid") — vertical scale, or if invalid, use the horizontal scale as vertical scale

Returns

  • void

getWidth(): integer

Gets the width of the underlying bitmap

Returns

  • integer

getHeight(): integer

Gets the height of the underlying bitmap

Returns

  • integer