Array Output

0 favourites
  • 8 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi and sorry for spamming the forum with this problem, but i dont find a solution <img src="smileys/smiley18.gif" border="0" align="middle">

    I filled a 2-dimensional array with values, but on access they keep "0".

    Can u help me put random entries of the array in the dataTxt textfield?

    capx here.

    I would love to continue this project, please help :)

  • The array has a width of 1 and a height of 2. So setting the element at, for example, (3,3) has no effect. It's outside the array! Click the array in the project or object bar to show its properties and make it as big as you need.

    I would strongly advise you use Tiled Background objects wherever possible. Creating lots of sprites is really bad for performance. A tiled background, no matter how big, is as fast as a single sprite. So if you create 2500 grass sprites it's 2500 times slower than using a tiled background the same size.

  • Did make the sprites for the array to insert the coordinates of the grid. As u can see, the background layer is the same but as tiled background. It's just for testing purposes.

    I guess if i want a grid, i need the count of squares which build the grid...in this case 50*50=2500. So i did set the width now "2500". Every square has 2 variables, X and Y, so i did set the height now to "2".

    Now the output doesn't work anymore, the textfield is not changing. What am i still doing wrong?

    link

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First thing to do in the startup is to set up the size of your array.

    Action Array:Set size. Three fields again Width (X), Height (Y) and Depth (Z).

    The array has a width of 1 and a height of 2. So setting the element at, for example, (3,3) has no effect. It's outside the array! Click the array in the project or object bar to show its properties and make it as big as you need.

    Your array is not of the right size. At the moment it is barely made of 2 elements.

    Also there are redundances and unuseful events in your code (but that's not the main problem).

    The stuff is you are relying on grass_q.Y to aim mapGrid's Y. This can't work, as grass_q.y may be as high as 900+ and mapgrid only has 2 Y.

    Anyway check the corrected capx. It outputs both Y = 0 and Y = 1.

  • Big Thanks :)

    I just dont understand why you use "loopindex" for X and ".id" for Y. I guess i could take both the same, because .id is set to loopindex before, right?

  • Yes.

    I was just messing around to find what was wrong with the version you posted at first. i just didn't change it back.

    Two ways of doing the same stuff.

  • I'll add you to my friends list on scirra :D

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