Arrays - Preview versus IOS Build (Bug?)

1 favourites
  • 8 posts
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • Hello - I have a strange issue.. I'm going to try and layout my thought process, screenshots, issue as best as possible.

    These arrays probably look weird and I will wind up remodeling them but for now this is what I came up with.

    Questions Array

    Answers Array

    Initialize the array

    I have a text box where basically it should scan Y = 0 and pick a random X to choose a random question in the questions array for the first row.

    it stores the X that was picked in a variable.

    The way the answers array is set up is that if the question that is asked is on questions(2,0) then the possible answers will be answers(2,0) , (2,1) and (2,2).

    So I'm setting three buttons and checking to see if these values are duplicates in any of the buttons and then changes the value if it is.. so that the buttons display the three possible answers.

    I can reload the page many times on the debug preview and everything works perfectly. However when I port to XCode and reload, almost every single time the button text is not right... Almost like its not reading the X index properly..

    For example, the question is 10 + 10 = ? then the x index on questions is 3. It should return the numbers in answers array at answers(3,0) (3,1) and (3,2) which would be 20,10,21 in random order.. but instead my buttons texts will be like 10,20,4... this mix up only happens on IOS simulation but I never notice anything wrong with the code when I run on html debug layout.

  • Hi DankTank

    Your events don't make sense:

    Example:

    Why do you call Ajax but after you not loading anything from Ajax?

    ============================================

    Also, what are you trying to do here? and why you calling it every tick

    Wouldn't be better to do all the changes once when you load the Array the first time?

  • I guess i'm not sure what would be a better way... I'm saying when "answers" is loaded from the json file then set the button text to a random value in the same column.

    The problem is I don't want duplicates but I also don't want the buttons to have the same value on every play through.

    So one time you may see 2 + 2 = ? and then the buttons (q1b1,q1b2,q1b3) could have values 4,5,12 in any order. But without the every tick statements maybe you would see 4,4,12 or some duplicates.

    Does that make sense? Hope I'm explaining okay.

    I know the code is probably bad but i'm confused why it seems to work 100% on preview but not on IOS build..

  • Okay, actually I take back what I said - it's just poorly written code and sometimes it IS incorrect on the html preview as well...

    Not sure the proper way to go about doing this though.

  • Okay, actually I take back what I said - it's just poorly written code and sometimes it IS incorrect on the html preview as well...

    Not sure the proper way to go about doing this though.

    Hi

    First, the Json file has to be loaded properly on the same event that you have right now

    -Ajax On Answers Completed

    Subevent load ArrayAnswers from Ajax.LastData

    Not sure why it never respect the spaces that you leave between lines I have to put these signs for line breaker

    ==============================================================================

    ===============================================================================

    Now that you will have the Array loaded:

    For your second question about Pick a random value from the Y but no repeats you could do:

    Have an empty 1D array set the size to = 0

    Then Repeat (ArrayAnswers.Height) Times >>>> Push back Lopindex

    Then you can pick a random Value by >>>>

    Add a local varriable example: "Temp_Index"

    Ser Var "Temp_Index" to int(random( ArrayAnswers.Height))

    -That will be your Y index number to pick the Question from ArrayAnswers

    -After that you picked the question you can delete the index from the 1Darray so you cannot pick it again

    Then repeat the same process if you have to pick more questions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry was on a vacation and didn't get to reply until now.

    So the first part i'm already doing correctly, the loading. It's in the "Initialize the array" screenshot in first post.

    Then you're saying to basically store three values in a 1D array that match the "answers" array. but only the answer for that question so it would be like the following for example -

    4

    5

    12

    As they are picked, delete the value and resize the array to one height smaller?

  • Sorry was on a vacation and didn't get to reply until now.

    So the first part i'm already doing correctly, the loading. It's in the "Initialize the array" screenshot in first post.

    Then you're saying to basically store three values in a 1D array that match the "answers" array. but only the answer for that question so it would be like the following for example -

    4

    5

    12

    As they are picked, delete the value and resize the array to one height smaller?

    Yes Push the Y index numbers of the questions into the 1D Array

    Then once you add them all of them, to pick one question random you can just do random(1D Arrya.Width-1)

    After you set the question just delete that index from the 1D Array so you don't select it again

    Note:

    you don't need to resize the Array as when you delete and index it resizes automatically

  • Think I was able to figure this out, appreciate the help!

    Running into some different issues now but I won't get into it in this thread.. thanks!

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