Is there a Condition for when an Object is created?

For questions about using Classic.

Post » Sat Jan 22, 2011 3:53 pm

Hi all, I've been experimenting with Construct and finding it very well designed and intuitive for game design. I'd like to ask you for some help on this issue, I couldn't find any reference in forum or searches:

I wish to have Objects created dynamically, and to have some code performed when an object is created. Is there a Condition, or otherwise a way to "catch" when an object is created, to initialize it? Right now, the only way I can think of is creating a Function for every object, such as "UnitInitialize", "EnemyInitialize", and calling it after creating each object, which seems a bit overcomplicated.

Thanks
B
1
G
1
Posts: 2
Reputation: 429

Post » Sat Jan 22, 2011 5:12 pm

How about using a private variable?
If you set that objects variable to say 0, that could mean it is not created.
Then when you actually create the object set its variable to 1, and have a condition that checks if is 1.
Might need a trigger once on the comparison event.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Sat Jan 22, 2011 5:16 pm

You can just put the action right after the creation of the object, like:

+Create object "enemy"
>set "enemy" position to 0,0

It will select only the recently created object
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sun Jan 23, 2011 2:13 pm

Thanks for the tips! I've incorporated those into my code.

However, I think something along the lines of what I was requesting is something that would be pretty useful in Construct, for code organization and simplification reasons.
B
1
G
1
Posts: 2
Reputation: 429

Post » Sun Jan 23, 2011 4:54 pm

I think its probably good coding practise to use functions to create objects anyway, rather than having random object create triggers all over your event sheet.

I can see why it might be nice to have a "Initialize" sort of thing though
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Sun Jan 23, 2011 7:41 pm

I've recently studied a little Phyton, and there's something called "init" for objects. It's a place of the code where you put any code an object will run right after it's created. Maybe it's possible to use this kind of phyton code with construct, I dont know, and maybe on a new update a "object is initialized" condiction could be added
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sun Jan 23, 2011 8:16 pm

How would you deal with multiple instances?
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 13 guests