New Array not empty

0 favourites
  • 9 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Link to .capx file (required!):

    dl.dropboxusercontent.com/u/17275929/Temp/Bug%20Test%20-%20Array%20is%20not%20empty.capx

    Steps to reproduce:

    Create an array and test if it is empty - doesn't seem to be at start.

    Observed result:

    Array has a count of 1.

    Expected result:

    Array has an initial count of 0.

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: yes

    Operating system & service pack:

    Windows XP 7 x64 SP1

    Construct 2 version:

    r126

  • Try Construct 3

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

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

    Test if the array is empty. The array is empty when the total number of elements is zero, calculated as width x height x depth. Therefore the array is empty when any axis has a size of zero. This can be useful when using Array as a data structure (e.g. when pushing and popping values).

    Your array is 10,1,1 so it's not empty.

    If you want it to be empty, make its size 0,1,1 then it will be considered empty.

    Moved to closed as not a bug.

  • Ok, but I cleared it in the layout on start event...? ;) That acts like a bug to me, regardless.

  • Clear

    Set every element in the array to the number 0.

    The clear action sets the value of the elements of the array to 0, it doesn't change its size.

    When you clear your 10, 1, 1 array, you have 10 zeros when you try to get the value with the action array.at().

    The empty condition checks for the size of the array (its number of elements), not the values of its elements.

  • Ok, not sure why anyone would think "clear" should mean "set all to zero" *for arrays*. Usually it means to clear OUT the items. ;) Anyhow, ok, thanks. Is there a "delete all" action, because I don't see it (other than looping one by one). This just all seems silly to me. :)

  • Ok, never mind, I see the "Set size" clears the array. Man, I have to stop thinking like a programmer. LOL. Thanks.

  • I did read it, but I must have missed it still.

  • Don't hesitate to check the manual it contains the specificities of how Construct 2 works.

    Compared to "regular programming language" there are a few subtleties that are specific to C2.

    Once you get the hang of it it goes smoother.

  • I guess sometimes it's easy to assume, from a developer stand point, what things should do. I'll try to confirm better next time. ;)

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