As highlighted within the High Level Design Description — the structure of this Balloon Pop! game is organized around three collections (main, level1 and level2). This enables us to easily switch between the two active game levels, as well as switching between an active level and the front-end GUI. Defold uses message passing as the mechanism for controlling the switching between collections.
In this game, a collection proxy is established for the level1 and a second proxy is defined for the level2 collection — the load/unload procedures are controlled using msg.post statements, for example: msg.post(CURRENT_PROXY, “load”) or msg.post(CURRENT_PROXY, “unload”). The status of these collection processes are also based on messages, to include: message_id == hash(“proxy_loaded”) or message_id == hash(“proxy_unloaded”). These message interactions are explained as detailed comments within the source code.
The following subsections identify the Game Objects and Component Elements within each of these three collections:
Within Balloon Pop! — the main.collection is structured around five Defold Game Objects:
- background — which is the container for the background sprite image
- controller — which contains both the level1/level2 proxies and the main_menu Graphic User Interface (GUI)
- exit_controller — containing the exit_menu GUI
- info_controller — containing the info_panel GUI
- levelController — containing the level_controls GUI
The following image depicts the full outline of the main.collection, to include each of the component elements.
The level1.collection is structured around five Defold Game Objects:
- board — containing the background sprite
- createBalloon — which includes the factory for producing balloon Game Objects
- createExplosion — which includes the factory for producing explosion Game Objects
- cursor — which contains the collision object and the script file for the cursor Game Object
- game_level1 — which holds the script for this game level
The level2.collection is very similar to the level1.collection structure, focused on the same five Defold Game Objects, however, it includes a different board sprite, and different balloon characteristics than level1.
Helpful Hints – Defold Collections:
Within Defold, Graphical User Interfaces (GUI) consist of several standard components: (1) Nodes, (2) Textures, (3) Fonts, (4) Layers, (5) Layouts, and (6) Spine Scenes. For the example within this tutorial, we’ll be using a total of four GUI sets to represent the menu buttons, information panels, popup notices and flag variable status. Those four GUI sets are:
The following illustrations highlight the various GUI nodes which are included within each of these sets: