I have a Node2D with a script. The node2d is located at (0, 200). I have this script attached.
extends Node2D
func init():
pass
func _ready():
var tile_scene = preload("res://scenes/tile.tscn")
for i in range(9):
var tile = tile_scene.instance()
tile.set_position(Vector2(i * 50, 0))
get_parent().call_deferred("add_child", tile)
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
Now when I run this, the 9 objects i create start at 0,0, and increment in the X axis by 50 each time. But they are all situated on y = 0, but I thought since they were children of a Node2D sitting at (0, 200), they would all start at (0, 200) and move in the X direction.
What am I doing wrong? Thanks.