What could be clearing my arrays?

0 favourites
  • 14 posts
From the Asset Store
Basics sprites and tilesets to build a platformer game or prototype
  • In my first layout I'm setting the values for this array of help-screens. After it's done, I have it print a value to test if it worked alright, which succeeds. If I put that same line print on the next layout, it returns as 0. When I try doing this with an otherwise blank project, it works fine. Ideas?

  • are you sure your array is set to global?

  • Are you including the event sheet in which the array is populated on the layout in which you're trying to print it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • danuyos

    The arrays are indeed global.

    tanoshimi

    I've tried putting the include in other layouts, but it still doesn't work. Even if I totally move it to another layout, and put the exact same call to print as I did the main menu, it still returns zero. It seems as though the Event Sheet that populates only wants to work in one layout, and the arrays refuse to carry over to the others.

    I'm pulling my hair out over this thing at this point, cos it isn't making any sense. I must have spent 4 hours trying to figure this thing out today.

  • Time to post your .capx, I think...

  • :\ I don't really feel comfortable posting this whole project that we've been working on for months online. I'll try to cut out as much core stuff as I can while keeping the problem intact and come back.

  • Check the start of layout events in all sheets.

  • Did so. What I did that seemed to fix the problem was taking the array out of its family (deleted the family, deleting all references to it). Going to put it back together in steps to see exactly where things break down.

  • Confirmed: The only difference between the arrays clearing and not clearing is whether it is inside a family or not. Ashley is there something I'm overlooking?

  • Is the array in a container? Then deleting an object from the container might clear the array?

  • Yeah you're right adagar, the array disappears (array.count = 0) when you switch layouts or restart the same layout.

  • Yeah you're right adagar, the array disappears (array.count = 0) when you switch layouts or restart the same layout.

    ramones and... I assume that's not the behavior it's *supposed* to have?

    It doesn't seem to clear it out if it's not part of a family...

  • I shouldn't think so .. you should make a bug report.

  • This also happens to me, but I didn't pay any attention to it because I thought it was my code doing something wrong, and haven't had time to look into it yet.

    Basically, what I have is this:

    if keyboard "A" key is pressed AND array = 0 -> populate array

    And if I change layouts, the array goes back to 0. It's also global.

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