Construct 2 Dictionary Tutorial

Construct 2 dictionaries store data in key-value pairs. Think of a Dictionary as a table with one column for names of values and one column for values associated with the names. If you want a value from a Construct 2 Dictionary, you request the value associated with a key (keys are sometimes called “names”). You can also have Construct 2 get all the key-value pairs, one pair at a time, and do things with them, such as print out high scores.

If you know one or more programming languages, this may all sound familiar to you. The Construct 2 Dictionary is similar to associative arrays and hashmaps found in other languages.

Names (called keys) cannot be duplicated in a Construct 2 Dictionary. For example, if you have a Dictionary of high scores, you could store key-value pairs of Doug-35, Bob-99, and John-42, but you could not have two scores named “John” in the list. For example, Doug-35, John-42, and John-33 would not work because the key “John” is used twice.

Note to Advanced Programmers: You can get around the no-duplicate-keys limitation by having multiple minion-style Construct 2 Dictionaries keyed off values from a master Dictionary. It would work like foreign keys in relational databases. I won’t go into that now, but remember, having no duplicate keys in a table is not a limiting factor. It just requires some extra planning and work.

Dictionaries are extremely useful for storing lots of related data. Dictionary use is easy for old-time programmers, but dictionaries need explaining in more detail for newer Construct 2 game developers. So, here’s a Construct 2 project example that shows the basics of Construct 2 Dictionary use.

New Empty Construct 2 Project
Select a new empty Construct 2 project.

Continue reading “Construct 2 Dictionary Tutorial”