Explain "On Created"

Discussion and feedback on Construct 2

Post » Mon Mar 18, 2013 9:16 am

Hiya

I am just curious to know when exactly does "On Created" get called?

For example if you have Event#10 looping around and spawning objects, and those objects have an "On Created" much further down say event #100. What happens? Does it "jump" to event 100 then back to 10 (the loop) per created item?silkc22013-03-18 09:17:04
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Mon Mar 18, 2013 11:22 am

This is just a guess, but I think it would run the loop, then apply the trigger to all of the objects spawned when we get down to event 100.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Mar 18, 2013 11:25 am

Well , I could guess yes , But i'm not sure , never messed with loops
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Mar 18, 2013 11:48 am

Well even if it isn't a loop same question stands;

Create an object in event 20
Handle creation in event 100

Does c2 jump down and up?

Conversely:

Create an object in event 100
Handle creation in event 10

Does c2 jump up then down? ;)

I guess simply put are the created/destroyed events independent of event ordering..?
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Mon Mar 18, 2013 11:59 am

[QUOTE=silkc2]
I guess simply put are the created/destroyed events independent of event ordering..?[/QUOTE]

How events work

Since triggers run upon an event happening, they aren't checked in top-to-bottom order like other events. This means the ordering of triggers relative to other events is not important (except relative to other triggers of the same type, since triggers still fire top-to-bottom).
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Mar 18, 2013 1:18 pm

Construct 2 has a real event stack, meaning triggers can fire, a whole bunch of events can run in the trigger, and then it returns to where it left off. This isn't specific to 'On created', it happens with any trigger, and there are several kinds of triggers that can run during other actions/events (notably the Function object).

It's best not to think about it as "jumping up and down the event sheet", that's not quite accurate. It's more like this:

- Running a loop
---- Create an object
------- Trigger 'On created'
---------- 'On created' conditions, actions and subevents run
---- Next action in the loop after 'Create an object'

So it's more like temporarily nesting the trigger events beneath the action, then carrying on the action list.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Mar 18, 2013 1:37 pm

OK thanks very much, just trying to get a full understanding. :)
B
20
S
6
G
2
Posts: 157
Reputation: 3,109


Return to Construct 2 General

Who is online

Users browsing this forum: pablo7 and 14 guests