0 votes

I'm writing a script with a _draw() function attached to the root node (which is a referenceRect), and have an instance of this scene in my main scene. When I play just the uninstanced scene it draws as expected, but when displaying the main scene with the instanced scene as a child, nothing is drawn, although the _draw() function is executed. (debugged using print()). I checked the documentation but it says nothing about this. Am I doing something wrong?

Code for reference:

extends ReferenceRect

# class member variables go here, for example:
# var a = 2
# var b = "textvar"
var boxPos;
var boxSize;
var font;

func _ready():
    # Called when the node is added to the scene for the first time.
    # Initialization here
    font = get_font("mainFont");

func _process(delta):
#   # Called every frame. Delta is time since last frame.
#   # Update game logic here.
#   pass

func _draw():
    boxPos = self.get_global_position();
    boxSize = self.get_size();

Also, as a side note, is there a way to pass delta to the draw function, or will it automatically inherit it since update() is being called from the _process function?

asked Feb 16, 2019 in Engine by Wren (18 points)

1 Answer

0 votes

UPDATE: I realized the problem is not that it isnt being drawn but that its being drawn offscreen. I didn't understand how transformation worked (and actually I still dont really understand how transformations work in relation draw functions) and the draw coordinates were getting multiplied offscreen. (or something)

I'll figure it out.

answered Feb 16, 2019 by Wren (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.