API Reference › Screen — drawing › Screen.draw_number
method

Screen.draw_number

Screen.draw_number(x, y, value, color, scale)

Draws an integer as digits using the built-in font, without first turning it into a string — so it never allocates and is safe to call every frame for constantly-changing values. Use it for scores, timers, frame counts, health totals, and any HUD number, while reserving Screen.draw_text for fixed labels. It takes the same top-left position, color, and integer scale as draw_text. Negative values are drawn with a leading minus sign.

Parameters

xthe left edge of the first digit, in pixels
ythe top edge of the number, in pixels
valuethe integer to draw
colorthe digit color, e.g. a Color.* name or a 0xRRGGBB literal
scaleinteger size multiplier (1 = native size)

Example

program ScoreHud {
  var score: int = 0

  handler EarnPoints phase Update {
    score = score + 1
  }

  handler DrawWorld phase Render {
    Screen.clear(Color.MidnightBlue)
    Screen.draw_text(x: 6, y: 4, text: "SCORE", color: Color.White, scale: 1)
    Screen.draw_number(x: 52, y: 4, value: score, color: Color.Gold, scale: 1)
    Screen.show()
  }
}
← All symbols