Recreating educational game, but having trouble with arrays.

0 favourites
  • 3 posts
From the Asset Store
Create a boss fight with this easy to follow game pack. Recreate the classic attacks of Mutoid Man from Super Smash TV
  • 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?

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)