How do I spawn via array? [SOLVED]

0 favourites
  • 8 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • So im getting into arrays and after looking at some stuff online I found something to spawn a bunch of boxes in a row from an array. Sadly though whenever I run it, it just spawns the boxes all on top of each other.

    Any ideas of what im doing wrong here??

    EDIT: The issue has been resolved and the .capx linked below updated if anyone cares to check it out in future. Thank you for all the help!

  • Can we please see a capx?

  • Here you are good sir or madam. It's in the group New Inventory, I had originally started making an Inventory based on a Dictionary object but decided to use an Array instead. https://dl.dropboxusercontent.com/u/72974151/Array.capx

  • I'm not sure I follow fully, but when I run your capx the array seems to spawn the boxes correctly - in a line, rather than all on top of eachother. You are only using the X component of the array though (width) so if you used For each X, Y element instead of just each X you could make a grid rather than a line.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, signaljacker is correct.

    https://dl.dropboxusercontent.com/u/589 ... Array.capx

    Fixed (ps, had to shrink your array size to get this to prevent it from going offscreen)

  • Okay so I tracked down the issue. For some reason if I destroy the first instance of the Inv_Slot during Layout startup the boxes will just spawn on top of each other. If I leave that initial Inv_Slot object though it works. Not really sure why this is. Anyone have an idea? Also one last question on this is there anyway to create spacing between the boxes so they aren't all touching each other?

  • I figured it out now my bad yall. So because I was destroying the box at the begining the code had no box with which to reference a width so they just all spawned on top of each other. Basically changed it so they spawn at arr_Inventory.CurX*50+32 instead of the arr_Inventory.Curx*Inv_slot.Width+32. Now it works as I thought it should and has some good spacing on them. The .capx has been updated.

  • Did you not see the capx I just posted? I fixed it completely for you.

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