Array Object use

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I don't know if I'm just being dense, or if the structure and use of the Array Object is just really different to VB6 Arrays, but I just can't seem to do some basic stuff with it.

    What I'm trying to do is to put 3 bits of information into an array, 1 set of 3 for each of 6 sprites. Then at another time and place in the game, loop through the array and compare the second element (2nd bit of information) of each record (set of 3 bits of information) and depending on what the 2nd bit of information is; increase the value of a private variable.

    I can get the 1st and 2nd bits of information into the array, for the 1st sprite, but the 3rd bit overwrites the 1st bit or just messes up everything...I just can't seem to workout how to reference each element of an Array record - X,Y and Z.

    I've been through the Wiki page for the Array Object, but alas here I am.

    Can someone steer me in the right direction please...

  • To use an array object like this you need to get and set the value at x, xy, and xyz.

    Since you only have 6 items to track that shouldn't be too bad, but a huge array with all three dimensions could add a lot of memory, and processing.

    You would then set up a loop to set x at loopindex, x,and y at loopindex, and x,y,and z at loopindex.

    ....Might want to take a look at the Ini object.

  • Thanks newt.

    I had a look at the ini object and could use it, although I still think an array would be more efficient as the player is going to trigger the check at the end of each level, with new data.

    Are there any tutorials or examples of using an array? I've had a quick look but alas I've not found anything yet.

  • Isn't there a bug in accessing the Z dimension for the array object?

    As far as examples for arrays go. I use arrays in several places in Part 4 and Part 5 in the adventure tutorial. It shows how to loop through and read and write from X, and Y based on loopindex. I thought I ran into a bug when accessing Z, but maybe that was fixed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks scidave, typical - I'd had a look up to Part 2 of the tutorial. I'll go and have a look at the rest.

  • Hi. From my interpretation of the original post, it sounds as if you only need a 2-D array, like so:

    x1y1, x1y2, x1y3,

    x2y1, x2y2, x2y3,

    x3y1 ...

    Ok, so that may not be clear, but I made a simple example based upon what you described, and showing loops as well:

  • also, make sure you're using 1 indexing, and not 0 indexing, as you said you come from a visual basic background

    1 is first in Construct, not 0, there is no 0 index

  • Thanks everyone.

    I think I am now getting a handle on arrays following Silent Cacophony explanation

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