Multiple layouts: levels and menus
A game usually has several screens: menu, levels, victory, game over. Each is a layout, with its own event sheet.
Create a layout
In the Project panel, under Layouts, use the add button. The new layout appears in the list, with its sheet under Event sheets.
Objects belong to the whole project, so the Coin you made can appear in any layout.
Change layout
The System action Change layout switches the screen:
| Conditions | Actions |
|---|---|
Keyboard: Key released Return |
Change layout to Level1 |
In levels, use the same layout to restart:
| Conditions | Actions |
|---|---|
Player Y position > 800 |
Change layout to Level1 |
Carrying values between layouts
Global variables stay valid when changing layout, so the score and lives carry over to the next level. Layout and instance variables start again from their initial value.
A sequence of levels
Menu: Play button →Level1.Level1: reach the flag →Level2.Level2: reach the flag →Victory.- Any level:
Lives <= 0→GameOver; Return →Menu.
External events
When several layouts repeat the same logic (the scoreboard, say), create an external event sheet and include it in the layouts instead of copying events.
Tip: give layouts clear names (
Menu,Level1,Victory). You will type them in events.