@crysii1 said:
P.S. How do I properly format multiline code?
Just add an extra indent before copying from your editor or paste here, select the whole thing and from the menu with the paragraph icon(should say Format in the alt text when hovering the menu) you click on code.
In this case I just copy pasted from your post, and it already was indented when I pasted:
func create_sprites_from_directory():
var dir = Directory.new()
dir.change_dir("./images/")
dir.list_dir_begin()
var file = dir.get_next()
while(file != ""):
if (file == "." || file == ".." || file.get_extension() == "import"):
file = dir.get_next()
continue
imageCount = imageCount + 1
var position = Vector2(1920/2, 1080/2)
var imagetexture = ImageTexture.new()
var image = Image.new()
image.create(1920, 1080, true, Image.FORMAT_RGB8)
image.load("./images/" + file)
image.resize(1920, 1080)
imagetexture.create_from_image(image)
var sprite = Sprite.new()
sprite.set_texture(imagetexture)
sprite.set_position(position)
sprite.hide()
get_parent().add_child(sprite)
sprites.append(sprite)
file = dir.get_next()