Can I store all my objects X/Y into an array using "pick" ?

Get help using Construct 2

Post » Sun May 25, 2014 2:14 pm

Hi. I would like to store all my objects coordinates into an array . Does this work with a system -> pick all, or does this work only with a system -> foreach ?

I tried this but it doesn't seem to work :
Image
I already have an array with all my elements coordinates and their corresponding array index number (stored in an object variable as chronobject.arrayIndex). I just want to use this new condition to update their coordinates into this array.
Is it possible to do so like this? I tried with a foreach and it works perfectly, but I don't really want to use a foreach for some reasons.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Mon May 26, 2014 9:50 am

No, you have to use a loop.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Mon May 26, 2014 1:21 pm

Thank you.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Mon May 26, 2014 1:50 pm

Pick all means you are considering all instances, it is useful if you picked some instances but you want to have all picked once again (never happened to me to have to use it), pick all is automatic at the root of events, it does not imply that you will repeat for all instances treating each of them individually (actions will execute for all of them, but expressions will only use one reference instance).

For each means you will apply what is next to all currently picked instances of that object individually, for each is implied in a lot of objects conditions (not all of them, on timer is an exemple that does not imply it), which means that expressions will be evaluated separately for each object.

Right under your picking, I guess a for each is needed.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Mon May 26, 2014 2:32 pm

Thank you for your explanation. :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests