Drawing in the draw order
· One min read
The render.draw_*_2d verbs take a trailing options table. Its z_index puts a shape among the nodes of that index, over them and under the next.
#{ z_index: 1 }ondraw_circle_2d,draw_rect_2d,draw_arc_2d,draw_polygon_2d,draw_polyline_2d,draw_texture_2d,draw_line_2danddraw_text_2dplaces the shape at that index. Without one it draws over the scene.- A stroke placed at an index is a mesh, so its width in pixels holds at the camera's zoom.
draw_texture_2dtakesregion_originandregion_sizein the image's pixels and draws that part of it, the keys a sprite uses for its region.- A misspelt key is an error naming the keys a verb takes.
balaur importdraws a Godot node's_drawat the node'sglobal_z_index, and adraw_texture_rect_regionthrough the region.
render::draw_circle_2d(-1.5, 0.0, 1.4, [0.2, 0.9, 0.4, 1.0], #{ z_index: 1 });
render::draw_texture_2d("art/blocks.png", -5.0, 2.2, 1.5, 1.5, (),
#{ region_origin: [0, 0], region_size: [16, 16] });
