Inserting value in 2D array

0 favourites
  • 3 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Problem Description

    I tried to insert a new value "SUPER" in a 2D array on X and a value "100" on its Y .

    In the array, it duplicates "SUPER" (even if I add a value on Y axis)

    I might have done something wrong, since I'm not familiar with Arrays.

    Attach a Capx

    ____ sorry can't upload it ____

    Description of Capx

    Really basic. I have a 2D array and tried to insert a value in XY.

    When touched [Sprite]

    ArrayName >> insert "SUPER" at index ArrayName.At(index) on X axis

    Example:

    arrUnits >> insert "SUPER" at index arrUnits.At(arrUnits.IndexOf("unit5")) on X axis

    Steps to Reproduce Bug

    • Create a 2D array (XY) width 6, height 2, depth 1
    • On start of the layout, fill the array X & Y (with the value you desire. I used "unit0" to "unit6" on X and some values 1-100 for Y)
    • Add a touch event on Sprite
    • On touched Sprite, Insert "SUPER" on X and insert "100" on Y

    Observed Result

    ____ What happens? ____

    Notice that "SUPER" is written 2 times in the array (through the debugger)

    Expected Result

    ____ What do you expect to happen? ____

    Having "SUPER" written once, and 100 following SUPER

    like:

    index0: unit0,5

    index1: unit1,3

    index2: unit2,4

    index3: SUPER,100

    index4: unit3,2

    Affected Browsers

    • Chrome: (YES/NO) YES
    • FireFox: (YES/NO)
    • Internet Explorer: (YES/NO)

    Operating System and Service Pack

    ____ Your operating system and service pack ____

    Windows X Familly - Intel(R) Core (TM) i7-4770 CPU 3.4 GHz

    Construct 2 Version ID

    ____ Exact version ID of Construct 2 you're using

    Release 239 also tested in r243

    ____

  • No no no just no. This is how array dont work. Just no no no.

    Check how array work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found how to fix my issue that I was doing wrong.

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