0 votes

Hello every one,

i have an array with 4 texts in it and i want to print each of them once at time with spacebar... i tryed to use for cycle but it seems to print all the array at once.. thank you for your help

in Engine by (26 points)

1 Answer

+1 vote
Best answer
var index = 0
var array = ["text1", "text2", "text3", "text4"]

func _process(delta):
    if Input.is_action_just_pressed("ui_accept"):
          print(array[index]) #or $Label.text = String(array[index]) if you have a label
          index+=1
          if index == 4:
               index = 0 #reset to beginning
by (340 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.