You would save a lot of processing time if you stored these preloaded. You don’t need to load() them over and over again. preload() only loads a file once and caches it, and checks to see if it’s loaded before pulling it from disk again.
What are you expecting this code to do? Because right now you are reloading the same image about 60 times a second without caching for no apparent reason. You can remove it.
Then your other code would be:
func _ready():
paiting = paitings[index]
func _on_next_pressed():
if index != len(paitings) - 1:
index +=1
else:
index = 0
paiting = paitings[index]
func _on_last_pressed():
if index != 0:
index -=1
else:
index = len(paitings) - 1
paiting = paitings[index]
Yes i was wrong about the process, and the loads, i now changed it to preloads, and change only when pressing the buttons. strangely it still doesnt work.
You need to reassign it to your sprite2d, store this : @onready var paiting = $Sprite2D
Instead of the texture reference as you override it and reassign directly : painting.texture = paitings[index]