Recreating educational game, but having trouble with arrays.

Get help using Construct 2

Post » Fri Oct 23, 2015 9:13 pm

I am an experienced Flash AS3 programmer, focusing on educational games for kids, but am trying to create games now using Construct 2. I am having no issues with understanding most of the logic of the process, but am having issues with the configuring of the data.

I am attempting to have a math problem appear and then have 5 answers appear also on the screen. Then, the student has to choose an answer. Once they do that, the game will check to see if the answer is correct. If it is, it moves on to the next questions and fills in the question and answers again. Like I said, the logic is easy enough if I can just make the game pull a random number from my arrays.

In AS3, my arrays looked like this:

aThree[0] = ["3 x 0", "2", "3", "0", "1", "4", "0"];
aThree[1] = ["3 x 1", "3", "5", "2", "16", "9", "3"];
aThree[2] = ["3 x 2", "2", "6", "12", "8", "4", "6"];
aThree[3] = ["3 x 3", "6", "8", "10", "9", "14", "9"];
aThree[4] = ["3 x 4", "8", "9", "3", "4", "12", "12"];
aThree[5] = ["3 x 5", "15", "16", "4", "9", "10", "15"];
aThree[6] = ["3 x 6", "10", "18", "9", "12", "6", "18"];
aThree[7] = ["3 x 7", "18", "10", "21", "24", "30", "21"];

Can anyone assist as to how I would create arrays of this style that could be pulled from to fill the text in my game? :D
B
3
Posts: 9
Reputation: 198

Post » Sat Oct 24, 2015 5:14 am

@fun4thebrain

Construct 2 doesn't have as simple a way to load an array.
The two easiest ways are to build a json string to load into the array, or use TokenAt to loop through a delimited string...

json example = "{'c2array':true,'size':[2,7,1],'data':[[['3 x 0'],[2],[3],[0],[1],[4],[0]],[['3 x 1'],[3],[5],[2],[16],[9],[3]]]}"

token delimited string = "3 x 0|2|3|0|1|4|0|3 x 1|3|5|2|16|9|3"

see: https://www.scirra.com/forum/initialize-an-array_t117058 for more...
B
98
S
35
G
20
Posts: 438
Reputation: 17,875

Post » Sat Oct 24, 2015 5:27 pm

Thanks so much. I have now figured out how to convert my as3 arrays into JSON arrays in Flash and then basically import them into a construct 2 array using Ajax. I will be testing this out today. Hopefully it works because I have tons of arrays for all different types of math problems that will be hard to reconfigure otherwise.

You have been a great help! :D
B
3
Posts: 9
Reputation: 198


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], jezjones24, maranpis and 25 guests