Main menu:
Now head over to the Event Editor.
The usage of groups makes up the premise behind this tutorial. Why groups? Groups can add tremendous organization to your code. You can label different sections of code different names and enable/disable these different sections at different times, as demonstrated in this tutorial.
So back at the Event Editor, create a new group called "Main Code". Within this group add the following line of code:
Always
Add '1' to Counter Object
Now make another group called "Pause/Resume Code" outside of the "Main Code" (Pause/Resume Code should not be within Main Code).
Within "Pause/Resume Game" add:
User Clicks on "Pause/Resume Game Object"
Only one action when event loops
Toggle Flag '0' of "Pause/Resume Game Object"
When you toggle a flag, you simply switch its state either from off to on, or on to off.
Now two lines of code need insertion, both under the group "Pause/Resume Code."
The first line
"Pause/Resume Game Object" Flag '0' is 'ON'
Only one action when event loops
Disable Group "Main Code"
Change Animation of "Pause/Resume Game Object" to (the other animation sequence within the Pause/Resume Game Object)
You may want to loop the secondary animation of the "Pause/Resume Game Object" so that it does not go back to the stopped animation when/if the secondary animation stops
The second line:
"Pause/Resume Game Object Flag '0' is 'OFF'
Only one action when event loops
Enable Group "Main Code"
Change Animation of "Pause/Resume Game Object" to "Stopped" (or the first animation for this object)
If all worked out well, then whenever you click the "Pause/Resume Game Object" the counter will either pause or resume incrementation. Why does this work?
When a group is disabled, MMFusion skips over the group and all internal sub-groups. As such, when you click on the "Pause/Resume Game Object" and the game is paused, the counter will increment again because the "Main Code" group will be re-enabled.
With this in mind, pre-built code such as the default movements and animations will continue even when the "Main Code" group is disabled. You will need to use alternative actions in the Event Editor to pause these code snippets.
What you'll need:
One Active Object with Bouncing Ball Movement
Initally, just create a new active object and give it the Bouncing Ball Movement (give the ball a slow speed). Then try to pause the game. Notice how the ball continues to move even though the game is "paused". This is because the code for the Bouncing Ball Movement is internalized. In order to get the Bouncing Ball Movement (and other default movements) to pause when the "Main Code" pauses, you will have to do one of two things when you disabled "Main Code"