cybereality Great, thank you!
My solution is now to make a class DrawCircle.
Then I can make a new circle by instantiating a new object of the circle class.
And if I don't need the circle any more, I queue_free() the circle class object.
class_name DrawCircle
extends Node2D
# Declare member variables here.
var node
var center
var radius
var color
# Workaround to make get_class() and is_class() also work for custom classes.
# This overrides the get_class() and is_class() methods and returns your
# custom class name correctly.
func get_class():
return "DrawCircle"
func is_class(value):
if value == "DrawCircle":
return true
else:
return false
func _init( _node, _center:Vector2, _radius, _color ):
node = _node # parent node under which the child node is created
center = _center
radius = _radius
color = _color
node.add_child(self)
return self
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func _draw():
draw_circle(center, radius, color)