Why is it useful to have naming conventions in your game projects? Well, to help you find things quickly and easily.
You will have noticed, for example, that once you have more than a handful of sprites or text objects, or a few global variables, it can be difficult to tell them apart.
It can also be difficult to remember what purpose things have. For example, just what purpose does Variable4 have? Or
So here are my tips for creating your own naming conventions in Construct 3. This will be useful if you are looking at any of our game examples.
Underscore & Camel Case
One important thing to note is that you can not have spaces in your Construct 3 names. Therefore to make things easy to read, either use underscore (ie g_variable) or use camel case (ie gVariable).
What’s camel case…??
Camel case is where words are written without spaces and using capital letters to differentiate the words (ie camelCase or CamelCase). It’s called camel case because the capital letters give the words the outline of a camel’s hump.
Event Sheets and Layouts
I rename Event Sheets and Layouts so it’s straight forward to see what their purpose is. For example e_start, e_game. Or l_start, l_game.
While this isn’t important when working with just one or two layouts, but it certainly helps as you build bigger games.
Sprites
I rename sprites with meaningful and short names and where possible I try to use common names if appropriate so that the items are listed together in the project bar.
For example, if I had two types of animals, I would name them an_pets, an_farm (or anPets, anFarm), so they are listed together in the project panel. Note how I have shortened ‘animal’ this is because if names are too long, it’s difficult to see the whole name in the window when working on a small monitor (which I do).
Text
I rename all my text objects starting with txt_ followed by something descriptive and short. For example, if it’s a text object which gives instructions I might name it ‘txt_instr’. This keeps all text objects together. This certainly makes it easier to find things than this:
Global Variables
I rename all my global variables starting g_ . Therefore I might have a global variable called g_play. I find this very useful for a number of reasons. First, it helps my when I am ‘reading’ an event sheet as it’s easy to determine what is an global variable compared to an object, and it is also easier to find the global variable when looking through dropdown boxes.
Instance Variables
I start all Instance Variables with iv_ . So I might have an instance variable called iv_color.
Arrays
This is another one that’s super-useful to rename to something meaningful. While you may remember that array4 is used to collect something-or-other when you are working on the game, come back to it later and it might not be so obvious. Therefore I rename arrays like this arr_colors. This also keeps arrays together in the Project Panel.
Comments
One other useful thing to remember is the Comment option. You can add comments anywhere on the Event Sheet and this is really useful for making notes of what different sections do – or even things to be done the next time you open a project.
Anyway… while this isn’t essential, having a good naming convention will definitely be useful as you start creating bigger games, and it’s a good habit to get into 🙂