In my game, I use code to change the sprite using a sprite sheet through an index. I would like to leave a different index for the first element of the snake, so that when changing the sprite (pressing the space bar). All elements were changed except the first one. How can I implement this?
snake code example:
extends Panel
static var index : int = 0
func _process(_delta):
variate\_texture()
func variate_texture():
$Sprite2D.region\_rect.position.x = index \* $Sprite2D.region\_rect.size.x
main code example:
func _process(_delta):
if Input.is_action_just_pressed("select_color"):
snake[0].index += 1
if snake[0].index > 2:
snake[0].index = 0
https://github.com/ScelCoding/Question/tree/main - a link to the github project with my question.