Explain "On Created"

  • 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?

  • 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.

  • Well , I could guess yes , But i'm not sure , never messed with loops

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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..?

  • I guess simply put are the created/destroyed events independent of event ordering..?

    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).

  • 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.

  • OK thanks very much, just trying to get a full understanding. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)