Arrays and Loops

For questions about using Classic.

Post » Tue Sep 23, 2008 3:07 am

What I'm attempting to do in this cap is save the location of every sprite instance and load it back in when a user returns to the layout.

So far I have been able to do this with only one instance when I was using a slightly different structure and I can't figure out why I cannot do it with more than one.

I must be missing something to have had it half working so any help is appreciated. I tried my best to explain my methods in the cap file itself. Thanks for your time!
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Tue Sep 23, 2008 4:04 am

I couldn't really make any sense of your CAP, but I can tell you that when positioning the blocks after array loading, you don't want to use the For Each action, otherwise all blocks will be moved to that position. Anyways, I whipped up a quick example that will do what you want to do in only 2 events(one for saving, one for loading):

Array Loading Example

Hope that helps. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Sep 23, 2008 8:52 pm

What does setting a space on the index to "sprite", do?
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Tue Sep 23, 2008 8:56 pm

That's just to tell it that there is coordinate information below that cell. If it sees "sprite" in a cell, it will create a sprite and set it's X and Y coordinates to the values in the cells below "sprite". That's the best I can explain it. :P There are probably better ways to do it, though.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Nov 25, 2008 5:47 pm

[quote:1jb05inn]I couldn't really make any sense of your CAP, but I can tell you that when positioning the blocks after array loading, you don't want to use the For Each action, otherwise all blocks will be moved to that position. Anyways, I whipped up a quick example that will do what you want to do in only 2 events(one for saving, one for loading):

Array Loading Example

Hope that helps. :)
[/quote:1jb05inn]

Link is down.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Tue Nov 25, 2008 6:16 pm

The link is down because he made this [url:1j7765b2]http://www.scirra.com/phpBB3/viewtopic.php?f=16&t=1478[/url:1j7765b2]

Which is loads better.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests