How do I spawn via array? [SOLVED]

Get help using Construct 2

Post » Thu Mar 24, 2016 3:01 am

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.

Image

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!
Last edited by VictoryX on Thu Mar 24, 2016 5:01 am, edited 1 time in total.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,501

Post » Thu Mar 24, 2016 3:04 am

Can we please see a capx?
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 522
Reputation: 19,596

Post » Thu Mar 24, 2016 3:12 am

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
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,501

Post » Thu Mar 24, 2016 3:47 am

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.
B
64
S
25
G
4
Posts: 204
Reputation: 6,993

Post » Thu Mar 24, 2016 3:53 am

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)
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 522
Reputation: 19,596

Post » Thu Mar 24, 2016 3:58 am

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?
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,501

Post » Thu Mar 24, 2016 4:02 am

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.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,501

Post » Thu Mar 24, 2016 4:06 am

Did you not see the capx I just posted? I fixed it completely for you.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 522
Reputation: 19,596


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish and 14 guests