Event Sheet Processing

Discussion and feedback on Construct 2

Post » Tue Oct 04, 2011 5:23 pm

There are certain points in the processing of an event sheet for which I need some clarification.

I found this from deadeye in the CC forums:

[QUOTE=deadeye] "For Each" is a loop. Think of your events like so:

1. Top of event sheet

2. Do some stuff

3a. Loop fifty times                  <--- this is your For Each
    3b. Do stuff fifty times
    3c. Go back to 3a fifty times

4. Do some more stuff

5. Go back to Top of event sheet


The event sheet is read from top to bottom, and then starts over again. Since the whole event sheet itself is a loop, then the For Each is basically a loop within a loop.[/QUOTE]

From what I understand, the whole event sheet is processed every tick, and there are 60 ticks per second, which (obviously) means the event sheet is processed 60 times per second.

If I have a For loop embedded in the event sheet, does the processing of the rest of the sheet stop while the For loop is processed, then the processing continues on with the next event after the For loop? If so, what happens if the processing of the For loop takes a "long" time, say 2-3 seconds? Doesn't that throw off the 60 ticks per second processing of the even sheet?

If someone could clarify how this works, I would greatly appreciate it. I like the concept of the event sheet, but as I get deeper into it, I am realizing just how ignorant I am.

Thanks!Wastrel2011-10-04 17:25:15
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Tue Oct 04, 2011 6:14 pm

[QUOTE=Wastrel]From what I understand, the whole event sheet is processed every tick, and there are 60 ticks per second, which (obviously) means the event sheet is processed 60 times per second.[/QUOTE]

Mostly correct - some events are skipped, like subevents of an event that didn't run, or events in a deactivated group. Ticks per second is determined by the frames per second (one rendered frame for each pass through the event sheet), which can vary depending on monitor refresh rates, vsync, etc.

[QUOTE=Wastrel]If I have a For loop embedded in the event sheet, does the processing of the rest of the sheet stop while the For loop is processed, then the processing continues on with the next event after the For loop? If so, what happens if the processing of the For loop takes a "long" time, say 2-3 seconds? Doesn't that throw off the 60 ticks per second processing of the even sheet?[/QUOTE]

Because events are run top to bottom, it's not that processing on the rest of the sheet stops, it's that construct hasn't gotten to it yet because it needs to complete the processing on the loop first. As such, ask construct to do a lot in a loop, and construct will simply sit there until it gets the job done, which can reduce the frame rate. The same thing happens if you put more sprites on the screen than the graphics card can handle - it can't keep up, so the frame rate is reduced.

You might want to check out my for each tutorial: http://www.scirra.com/forum/tutorial-when-to-use-for-each_topic39775.htmlArima2011-10-04 18:15:18
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Tue Oct 04, 2011 10:54 pm

This post from Ashley explains some of the differences between C2 and CC.
It might help you getting a better understanding of the event sheet processing too.

In C2 you need a less lot "For each" loops than you did in CC.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Oct 05, 2011 12:02 am

[QUOTE=Kyatric]In C2 you need a less lot "For each" loops than you did in CC.[/QUOTE]

Actually, all the behavior described by Ashley in that post is the same in CC. As far as I know, CC doesn't require any more for each loops than C2.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed Oct 05, 2011 1:59 pm

Thank you both for your insight and the links. I think it's actually starting to sink in.
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 1 guest