Skip to content

GUIText

Constructor

new GUIText(text: string, fontSize: number, fontFamily: string, color: string, fontWeight: number);
NameTypeDescription
textstringText to be displayed
fontsizenumberFont size in pixels
fontFamilystringCSS font family
colorstringCSS text color
fontWeightnumberCSS font weight

Implements

  • GUIElement

Members

public text: string; // Holds current text value
public fontSize: number; // Holds current font size value
public fontFamily: string; // Holds CSS-like font family value
public fontWeight: number; // Holds CSS-like font family value
public color: string; // Holds CSS-like color value
// Holds position as an { x: number; y: number } object
// Default value: { x: 0, y: 0 }
public position: { x: number; y: number } = { x: 0, y: 0 };
// Returns current text width
// Calculated with the object's function
get width(void): number;
// Returns current text height
// Calculated with the object's function
get height(void): number;
// It calculates text with using a false canvas
// Used byt width getter
protected getTextWidth(void): number;
// It calculates text with using a false canvas
// Used byt width getter
protected getTextWidth(void): number;
// It's called whenever engine renders the element
// It comes from GuiElement interface
// *PARAMS*
// ctx: CanvasRenderingContext2D - context used to render the element on the canvas context of the game instance
public render(ctx: CanvasRenderingContext2D): void;