In this tutorial, you will discover how to use the “Enumeration” type variable. This type of variable allows you to define a set of items, such as a hand in a deck of cards, ingredients in a recipe, or books in a school bag.
The scenario aims to compare the set with the elements to find. When all of the items are found, the set will be considered complete. Then, the consequence can take place in the system of conditionals, like opening a padlock.
Before you begin, click to watch the final rendering of this example.
To perform this experiment, you will need the items below:
- closed padlock pictogram
- opened padlock pictogram
Note that you can find these items in the Speedernet Sphere online library.
Once the elements are in place, here are the steps to follow:
- Add an enumeration variable
- Define the integration needed to change the value
- Create the interaction after changing the variable
Step 1: Add an enumeration variable
At the bottom of the elements column, open the variables window (the cogwheel opposite the word “VARIABLES”, bottom right of the image below):
Click on “add enum” (see below). Then, click on the cogwheel icon.
The next window will allow you to edit the variable (see below).
You can optionally rename the variable to find it more easily in the “Conditionals” window. In our scenario, we called it “Indices scène”. Finally, fill in the values, one for each index as shown above.
It is imperative to ensure that no index is checked since no index has yet been found by default.
Now you have a variable and its components. It is time to create the conditions for its completion.
Step 2: Define the integration needed to change the value
First, create a padlock from an image to which you will associate two aspects: closed and open. By default, you must display aspect no. 1, closed padlock (see below). Aspect no. 2, open lock, will be used when the user has found all the clues.
Then, just create the clues using a trigger for each one. By default interactive and invisible, it changes state to become visible (visible outlines) and non-interactive once clicked (see image below).
When clicking on an index, the state of the trigger changes and the variable is updated by adding the value of this index. The corresponding implication is illustrated below:
Step 3: Create the interaction after changing the variable
When all the indices have been added to the variable, it becomes complete. So, It triggers the consequence: changing the appearance of the padlock from closed to open. To do this, open the Variable conditionals window by clicking on the arrow at the bottom of the element column (located next to the cogwheel). Then just create an conditional as shown in the image below:
You now just have to test your scenario!
This tutorial presents one use case of the enumeration variable. You can use this variable for other types of scenarios.
Share with us the scenarios in which you will use this type of variable and give us your feedback!
See you soon for the next tutorial!
I also invite you to consult the following tutorials: