Die Funktion _draw() wird einmal zu Beginn des Programms abgearbeitet. Die gezeichneten Formen sind mit dem übergeordneten Node verknüpft. Ändert sich dessen Position, werden auch die gezeichneten Formen verschoben.
Sind die Formen variabel gestaltet, müssen wir bei einer Veränderung die Funktion _draw() erneut aufrufen, dies erreichen wir, in dem wir die Funktion update() aufrufen.
func _draw(): var koor = Vector2(0,0) var koor2 = Vector2(150,-150) var farbe = Color8(255,0,0,125) var farbe1 = Color8(0,255,0,125) var farbe2 = Color8(0,0,255,125) var start_gross = Rect2(Vector2(0,0),Vector2(-100,-100)) var polygon = PoolVector2Array() polygon.append(Vector2(0,0)) polygon.append(Vector2(50,0)) polygon.append(Vector2(100,100)) # ---------------------------------- draw_circle(koor,100,farbe) draw_colored_polygon(polygon,farbe1) draw_line(koor,koor2,farbe2,5) draw_rect(start_gross,farbe2)
Bei dem Mutter-Node handelt es sich um ein Sprite2D. Auffällig ist, dass die draw-Objekte über dem Sprite liegen.
Member Functions
void | _draw ( ) virtual |
float | draw_char ( Font font, Vector2 position, String char, String next, Color modulate=Color( 1, 1, 1, 1 ) ) |
void | draw_circle ( Vector2 position, float radius, Color color ) |
void | draw_colored_polygon ( PoolVector2Array points, Color color, PoolVector2Array uvs=PoolVector2Array( ), Texture texture=null, Texture normal_map=null, bool antialiased=false ) |
void | draw_line ( Vector2 from, Vector2 to, Color color, float width=1.0, bool antialiased=false ) |
void | draw_multiline ( PoolVector2Array points, Color color, float width=1.0, bool antialiased=false ) |
void | draw_multiline_colors ( PoolVector2Array points, PoolColorArray colors, float width=1.0, bool antialiased=false ) |
void | draw_polygon ( PoolVector2Array points, PoolColorArray colors, PoolVector2Array uvs=PoolVector2Array( ), Texture texture=null, Texture normal_map=null, bool antialiased=false ) |
void | draw_polyline ( PoolVector2Array points, Color color, float width=1.0, bool antialiased=false ) |
void | draw_polyline_colors ( PoolVector2Array points, PoolColorArray colors, float width=1.0, bool antialiased=false ) |
void | draw_primitive ( PoolVector2Array points, PoolColorArray colors, PoolVector2Array uvs, Texture texture=null, float width=1.0, Texture normal_map=null ) |
void | draw_rect ( Rect2 rect, Color color, bool filled=true ) |
void | draw_set_transform ( Vector2 position, float rotation, Vector2 scale ) |
void | draw_set_transform_matrix ( Transform2D xform ) |
void | draw_string ( Font font, Vector2 position, String text, Color modulate=Color( 1, 1, 1, 1 ), int clip_w=-1 ) |
void | draw_style_box ( StyleBox style_box, Rect2 rect ) |
void | draw_texture ( Texture texture, Vector2 position, Color modulate=Color( 1, 1, 1, 1 ), Texture normal_map=null ) |
void | draw_texture_rect ( Texture texture, Rect2 rect, bool tile, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null ) |
void | draw_texture_rect_region ( Texture texture, Rect2 rect, Rect2 src_rect, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null, bool clip_uv=true ) |
RID | get_canvas ( ) const |
RID | get_canvas_item ( ) const |
Transform2D | get_canvas_transform ( ) const |
Vector2 | get_global_mouse_position ( ) const |
Transform2D | get_global_transform ( ) const |
Transform2D | get_global_transform_with_canvas ( ) const |
Vector2 | get_local_mouse_position ( ) const |
Transform2D | get_transform ( ) const |
Rect2 | get_viewport_rect ( ) const |
Transform2D | get_viewport_transform ( ) const |
World2D | get_world_2d ( ) const |
void | hide ( ) |
bool | is_local_transform_notification_enabled ( ) const |
bool | is_set_as_toplevel ( ) const |
bool | is_transform_notification_enabled ( ) const |
bool | is_visible_in_tree ( ) const |
Vector2 | make_canvas_position_local ( Vector2 screen_point ) const |
InputEvent | make_input_local ( InputEvent event ) const |
void | set_as_toplevel ( bool enable ) |
void | set_notify_local_transform ( bool enable ) |
void | set_notify_transform ( bool enable ) |
void | show ( ) |
void | update ( ) |