Sub Events Question

Discussion and feedback on Construct 2

Post » Fri Oct 31, 2014 6:56 am

Do sub-events always run in serial (top-down) and wait for each other to finish in the same order?
i.e, do bottom sub-event wait for top sub-event to finish

example
main even( condition1 )
sub-event1( condition 1.1 )
sub-event2( condition 1.2 )
sub-event3( no-condition - only action)

if sub-event2 condition is met and its actions are CPU hungry, will sub-event3 run before sub-event2 finishes or wait for it?
B
7
S
1
Posts: 26
Reputation: 530

Post » Fri Oct 31, 2014 7:30 am

Events are read vertically from top to bottom, every frame. An event isn't checked until it finishes checking previous events.

So subevent 3 will be checked after subevent 2.
B
151
S
75
G
20
Posts: 1,793
Reputation: 22,749

Post » Mon Jan 05, 2015 12:58 am

I beg to differ. Sorry for bumping this not-so-old topic, but I see everywhere people saying that sub-events are run one after the other, which appears to be wrong. And I wish it'd be true, otherwise I wouldn't have all those problems...

So far in my experience, sub-events will run one after the other only if every sub-event is a sub-event to the previous one. It won't work if they are all sub-events of one main event. And that's hard to deal with when using loops. The attached .capx file shows what I mean.

If anyone knows how to overcome that, I'm all ears.
You do not have the required permissions to view the files attached to this post.
B
11
S
3
G
3
Posts: 206
Reputation: 2,379

Post » Mon Jan 05, 2015 1:27 am

okay @Kan you've got me thoroughly confused now.. Somebody come along and explain this please?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Mon Jan 05, 2015 1:28 am

@Kan
The issue you are having has to do with C2s inability to pick objects in a sub-event immediately after creation. It isn't a sub-event issue in general, only in this specific case. The behaviour is (unfortunately) expected, had had been discussed many times on the forum. Event 4 is being run sequentially, the Sprite object just can not be picked yet.
ImageImageImage
B
71
S
22
G
248
Posts: 3,761
Reputation: 138,073

Post » Mon Jan 05, 2015 2:28 am

Is there also such an exception with the 'Wait' action?
You do not have the required permissions to view the files attached to this post.
B
11
S
3
G
3
Posts: 206
Reputation: 2,379

Post » Mon Jan 05, 2015 4:38 am

Wait IS asynchronous. Wait takes all actions below it AND its sub-events and calls them after the time has expired. Event 3 is not in the Wait scope so it will get called immediately (in this case, immediately after the 1 second wait, overriding anim2). The last Wait call in event 2 does nothing.
ImageImageImage
B
71
S
22
G
248
Posts: 3,761
Reputation: 138,073

Post » Mon Jan 05, 2015 5:40 pm

Alright, thanks. I'm happy now I know those two things. :)
B
11
S
3
G
3
Posts: 206
Reputation: 2,379


Return to Construct 2 General

Who is online

Users browsing this forum: Ashley and 9 guests