Draw a variable on screen but without using label node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Huder

It is possible to draw a variable on screen but on scene that has no label node?
I want it only for debug purpose. It will be like using print() but in realtime on screen

:bust_in_silhouette: Reply From: kidscancode

You can use draw_string() for this:

See Custom Drawing in 2D for more information.

What i need to put in font argument when i want use default one?

Huder | 2018-04-21 18:02

You need a Font resource, which you can load() if you already have one (recommended), or create dynamically.

How you load a font depends on whether you want to use DynamicFont or BitmapFont. The latter is a little easier, especially if you already have a “.fnt” file. I recommend reading through those docs to see how it all works.

It’s probably easiest to use the editor to add the font to a node (such as Label) and then save the resource. Once you have a saved resource, you can reuse it anywhere you want.

kidscancode | 2018-04-21 18:17