Deleting item from Array makes text element disappear?

0 favourites
  • 7 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • Hi, I finally figured out how to get my game to delete an item from the array using:

    -> QuestionArray: Delete index randomNumber from X axis

    I ran the game through debug and it works! I was stumped on it for a while, but it does delete questions as they are shown so they don't repeat.

    Now I have a new problem.

    Every so often when I click to generate the next line of info, the text element that I use to show the data from the Array vanishes and only a blank space is shown.

    I thought maybe it was showing the empty spaces where the old data was, but after some testing that's not the case. The text boxes are actually disappearing like they've gone invisible or been destroyed. But there are no commands for them to do so and on top of that it's randomly and inconsistently occurring.

    I'm not sure what I'm doing wrong or what would cause that to happen?

    Here's the CAPX: http s://jmp.sh/v/XG3gFh394mtLhoDgKLcu

    If someone could take a peek, I'd be greatly appreciative.

  • I can't open your link, it tells me that the file has been removed.

    Make sure the text object is big enough (tall) to fix the text, otherwise it will not be shown. Also, try adding trim expression to remove any possible line breaks from the start of the text. For example:

    Set text to trim(Array.at(1))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, I'm not sure why or how that happened with the link.

    New link: http s://jmp.sh/zaiEXnF

    Backup link: http s://gofile.io/?c=tZnFOq

    The text boxes are definitely large enough. To better describe whats happening:

    1. Quiz questions & answers pop up

    2. User clicks answer, correct or incorrect is displayed

    3. Next question is displayed, above process repeats

    4. After about 3-4 questions, blank spaces & no questions or answers show up

    5. Clicking 2-3 times shows the "correct/incorrect" displays but nothing else.

    6. Then questions seem to resume and pick up right where they left off before the 'glitch'

    Every single question does eventually show up so I'm thinking it's definitely not the size of the text boxes.

  • That's because you are removing rows from the array, but still selecting random(0,9) index. Also, don't use round() with random, it causes non-uniform distribution of results.

    Change it like this:

    Set randomNumber to int(random(0,QuestionArray.Width))

  • Here's a screencast of the issue also: http s://imgur.com/a/U3P7bWf

    Edit: Sorry, Didn't realize you'd responded already.

  • That's because you are removing rows from the array, but still selecting random(0,9) index. Also, don't use round() with random, it causes non-uniform distribution of results.

    Change it like this:

    Set randomNumber to int(random(0,QuestionArray.Width))

    ...Wow, that worked. Thank you!

    I'm still trying to understand the difference between the two. I read the manual on Arrays & Parameters but it didn't really cover this. Do you know of a tutorial that covers this more?

    If you don't that's okay, I'll still continue to do some searching. I'd like to be able to troubleshoot on my own if possible in the future.

  • I'm still trying to understand the difference between the two.

    The difference between the two what?

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