I'm trying to create a circumference with some sprites.
I wrote something like this:
extends Node2D
var radius
var center_screen = Vector2()
var shape_size
export var num_shapes = 5
var next_angle # in radiants
export (PackedScene) var Shape
func _ready():
center_screen = get_viewport_rect().size / 2
global_position = center_screen
radius = center_screen.x / 3
shape_size = (2 * PI * radius) / num_shapes
next_angle = (2 * PI) / num_shapes
for i in num_shapes:
var shape = Shape.instance()
call_deferred("add_child" , shape)
shape.position.y = radius
global_rotation = global_rotation + next_angle
But when i execute looks like only one shape is created, any help? Could be anything with the call_deferred?
https://gyazo.com/44cb09d36ae9446593dcecf42733d20b