Now you know that an event frame happens after all the events in the Event Editor execute. What happens though if you need to execute a series of actions within one frame, such as find the number of enemies with full HP? In these scenarios, you will use immediate events such as fastloops or ForEach loops. This guide will explain immediate events, the uses of fastloops and ForEach loops, and special properties of immediate events.
Immediate conditions, also called triggered events, are not checked every frame. Specific actions need to occur before these conditions trigger such as a collision between two objects (for this reason, immediate conditions cannot be negated. When this trigger happens, MMFusion pauses Event Editor and looks for any immediate events that match the trigger event. If any of these conditions match, the event(s) execute like normal conditions. If none match or all the checks have finished, MMFusion will resume where it left off in the event loop.
Immediate conditions have red text by default, but this can change via the preferences of MMF2. Examples of immediate conditions include:
Start of Frame
Player Presses Up/Down/Left/Right
Player Presses Button 1/2/3/4
On Fastloop "<fastloopname>"
As previously mentioned, fastloops are a special type of immediate condition. Fastloops are primarily used to:
Perform numerous calculations within one frame
Group, organize, streamline, and clarify code
Create callable functions within MMFusion
The concept of fastloops is simple:
You manually create and call a fastloop a specified amount of times
When MMFusion calls the fastloop, MMFusion immediately searches for all events that have the called fastloop name
If any events are found, MMFusion tries to execute the event
After a given number of iterations, either you manually end the fastloop or MMFusion end it
MMFusion resumes where it left off in the Event Editor
Order fastloops and ForEach loops into groups based on their name or function. Keep these groups deactivated until you need them. By using this technique, the application perform faster!
One of the most troubling issues with fastloops is fastloops have a hard time with object selection and object iteration. Fastloops do not naturally iterate through object instances. To do iteration, you used to have to spread a value (lets say ID) through the objects, run a fastloop X amount of times, compare this ID to the index of the fastloop, and hope that the object selection goes perfect. A lot of work just to iterate through some objects right? Now, this can be done with the ForEach Loop.
The ForEach Loop can be considered a specialized form of the fastloop used primarily for object iteration. It works in the same manner as regular fastloops with one major difference; the ForEach loop will take any objects in the current MMFusion object selection, and iterate through them with no need of complicated spread values or order-perfect condition manipulation.
As a bonus, you can add individual objects to groups which can then be used for your purposes. In Multimedia Fusion 2, you need to use the ForEach Loop extension to use ForEach loops. With introduction of Clickteam Fusion, this extension was natively integrated into the program
So we now know about immediate conditions, fastloops, and ForEach loops. Now what? The example file located in the introduction contains numerous examples of the uses, advantages, and disadvantages of these three concepts. Take a deep thorough look through each frame to find out how immediate conditions, fastloops, and ForEach loops are used.