Canvas
Contains a roku roBitmap which all game objects get drawn to.
Properties
bitmap(ifDraw2D) — bitmap GameEntity images get drawn tooffset(BGE.Math.Vector) — Position offset from screen coordinates (z value ignored)scale(BGE.Math.Vector) — Scale (z value ignored)renderer(Renderer) — Renderer for this canvasrendererOptions(RendererOptions)
Constructor
new Canvas(
gameEngine: Game,
canvasWidth: integer,
canvasHeight: integer,
options?: RendererOptions,
): CanvasCreates a Canvas object and bitmap
Parameters
gameEngine(Game)canvasWidth(integer) — width of canvascanvasHeight(integer) — height of canvasoptions(RendererOptions, optional, default: "{useBitmapPooling: true}")
Instance Methods
setSize(canvasWidth: integer, canvasHeight: integer): void
Changes the size of the canvas
Parameters
canvasWidth(integer) — width of canvascanvasHeight(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 offsety(float) — y offset
Returns
void
setScale(scale_x: float, scale_y?: float): void
Sets the scale of the canvas
Parameters
scale_x(float) — horizontal scalescale_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