Text and shapes from code
onRenderGui draws on top of everything, in screen coordinates. For HUD and menus, the interface built in the editor is the usual way.
function onRenderGui(self) drawText("PONTOS " .. self.pontos, 4, 4, colors.yellow) drawText("Fim de jogo", 100, 80, colors.white, "Titulos", 24)
drawRect(4, 30, 50 * self.vida, 4, colors.red) drawRect(4, 30, 50, 4, colors.white, false)endvoid onRenderGui() override { drawText(std::format("PONTOS {}", pontos), 4, 4, colors::yellow); drawText("Fim de jogo", 100, 80, colors::white, "Titulos", 24);
drawRect(4, 30, 50 * vida, 4, colors::red); drawRect(4, 30, 50, 4, colors::white, false);}- The built-in font has 8-pixel letters and supports accents. A number after the color scales it:
2= 16 pixels. - With the name of a project font (
.ttf) and the size, the text uses that font. - Centering with the built-in font:
x = (width - letters * 8) / 2.
Reference: Drawing.
