Hi, all, just started with Godot and even though i have some Unity experience (yeah, i know...) there were a few things I couldn't figure out:
- I made my Main node/scene which has canvas_layer, a colorRect background and hbox for card slots (each slot is basically a colorRect with a button to draw a card). I assumed (correct me if I'm wrong) that the best node for a simple card is ColorRect which i created on a separate node. When i try to draw/instantiate the colorRect node, i do not see it. I played around with the ordering but nothing. I have the same problem when i create a card as label, sprite2D, normal/neutral node, control node. It worked fine when I made my card out of canvas_layer node with colorRect as a child. However, I do not understand why?
The script is attached to my Main node and I use this very simple instantiate function i found online:
extends Node2D
var myCard = preload("res://layer_and_node.tscn")
func spawn():
var instance = myCard.instantiate()
add_child(instance)
func _on_button_pressed():
spawn()
Regarding the function, what is "add_child(instance)" for?
I tried to spawn/instantiate my card at the place of my slot by creating a default position which i link to the position of the slot but I couldn't make it work.
Any tips are appreciated!