I have a player scene (RigidBody2D
) with it's script.
I also have an IArrow.gd
(Node2D
) script that is used in player to help with input.
This arrow is a script, so it's never instanciated as a node in tree, but it holds variables that player uses.
Let's say I cannot add this IArrow.gd
as a child of the player node in player scene.
I have _draw()
functions in both player and IArrow.gd
.
I can make the player draw the arrow by putting draw_line
function in player's _draw()
function and passing it the variables of the arrow, but I cannot make the player draw this arrow by calling the arrow's _draw()
function inside the player's _draw()
function.
I would like to have the arrow have it's draw function separated from player and then called from player's script by typing something like arrow._draw()
in player's script. Is this possible?
NOTE
1. from the documentation, I see that draw_...
functions cannot be called outside the _draw()
function of any canvas node.
2. there is one more script between the player and arrow called input, but for the sake of simplicity and trying to find the reusability, let's just say that what I described above is how things stand.
3. when I put arrow._draw()
in player's _draw()
function I get this error