0 Favourites

# Event Sheet Processing

• 5 posts
• 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:

"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

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.

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!

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

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.

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?

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

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

• In C2 you need a less lot "For each" loops than you did in CC.

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.