Array Problem

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I've been working on this problem for an hour now and have no clue why it will not work.

    <img src="http://i.imgur.com/IbuGPeG.png" border="0">

    All I'm doing is saving an objects position into an array when a button is pressed. However it does not seem to be doing it all. The array size is 16,15,1 (I've tried much larger too) so I don't see how it could be outside of it. Also, I know it has something to do with saving because the element doesn't even exist in the .json file.

    When I load the value later it doesn't think anything is there and just sets it to 0, 0. I'va also had a text object set to display the 2 values every tick (and it shows 0, 0).

    Also, setting the values into X = 15+ will do this but X = 0-14 will work successfully.

    If anyone knows what is happening, a fix would be greatly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you loading the array from JSON somewhere in your event sheet? If you had saved an array of width 15 earlier and were loading that it would override the width of your array. Just a guess.

  • ramones Yes I am loading it from JSON, but I've saved the array as JSON when it was supposedly 16 wide and loaded that. Also I've checked the value of the array after it's set and before it's loaded but it's still 0,0.

  • Print out the width/height/depth of the array when the button is clicked. And make sure there's no stray spr_playerspawner at (0,0) and that there is a spr_playerspawner on the layout :)

    Either the array is the wrong size and the value isn't being set when the button is clicked or the value is being set to 0. If the array is the correct size you could try setting the value to -1 and see if it changes.

  • ramones just did that. it was in fact setting the array back to 15,15,1 before it added the values. I added a set size right before the setting value, then got the value from the array after it was set. That fixed it BUT, now when I load the array from json, it's still getting 0,0 (but the array is 16 wide now when it loads)

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