How do I loop through array and display as text?

Get help using Construct 2

Post » Fri May 15, 2015 4:10 am

I am trying to create a baseball simulator. One part of it is the roster of players, which I have put into an array. In my capx file, I have two teams with one chosen at random. How can I loop through the array and display the player's uniform number and name who is up to bat? I created a button that once clicked shows 3 outs, indicating the next player's number/name should show up. Thank you for your help!

loop-thru-array.capx
B
7
S
2
Posts: 34
Reputation: 670

Post » Fri May 15, 2015 8:14 am

Index = 0
Set Text to Roster.At(index)
Index ++

Something like this should work
B
12
S
3
Posts: 211
Reputation: 1,477

Post » Fri May 15, 2015 9:56 am

I do not know much about baseball...but
but maybe this can help..

capx> http://s000.tinyupload.com/index.php?fi ... 1649361859
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Fri May 15, 2015 4:04 pm

Thank you, Fireche, for the code, and thank you, korbaach, for the capx file. The file worked exactly as I wanted. Is there an advantage to loading the array data from a JSON string?
B
7
S
2
Posts: 34
Reputation: 670


Return to How do I....?

Who is online

Users browsing this forum: AndreasR, Artepi, karthikavnair, OBLIVION, Rable and 15 guests