Batch spawning objects

For questions about using Classic.

Post » Sat Feb 07, 2009 12:12 pm

Hello,

I have a parent object which spawns three identical child objects, each of which should have different private variables.

However, if I set it like:

>Parent Spawn 'Child'
>Set Child('Variable') to "eldest"
>Parent Spawn 'Child'
>Set Child('Variable') to "middle"
>Parent Spawn 'Child'
>Set Child('Variable') to "youngest"

All Child instances have the variable at "youngest". Shouldn't it automatically pick the newly created object? How do I make sure each child instance is correctly assigned a value?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Feb 07, 2009 1:18 pm

Right now actions operate on all the objects created in that event - the idea is if you do:

Create A
Create A
Create A
Set A's private variable 'foo' to "bar"

then all three are modified. By the change you are suggesting, that would not work in the above example, and would only change the last A. Do you still think it should be changed?
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Sat Feb 07, 2009 1:45 pm

I see, then I have to put each create object action into separate event. What would be the most efficient way to separate them, if for example I am creating numerous instances at the same time? Separate them with trivial subevents?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Feb 07, 2009 1:50 pm

Subevents would be best yeah.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sat Feb 07, 2009 1:51 pm

Yeah, a blank subevent (with no conditions) means the same as 'always', so just throw each create action in a blank subevent and you can control that instance uniquely.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Sat Feb 07, 2009 2:02 pm

Thank you. :)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests