What's a game without a player's score? Score is important to show users if they are winning or losing. Here's a simple way to create score for your game!

Create Your Scene

First, create a scene and add your layers to make your game. Once you've created your scene, add a text layer for score i.e. Score: 0. 

In my example, every time you drag the circle into the box, you get a point. 

Creating Interactions and Defining Variables

We're looking to increase the value anytime the player drags the circle into the box.
In order to capture score, we need to create a variable that will store the score. 

First, create the interaction that will define how your player can get a point. For example, I am going to select "Drag" and then define the trigger "Circle is dragged to Box." 

Create a variable by selecting "Set" in the action card and then add a new variable called "Score." 

In the Equal to section, this is where you define score. My example will define score as anytime the circle gets dragged into the box, the player will get 1 point. Therefore, I will define score as "Score + 1."

Tip: At default, Lightwell defines score at 0. Therefore, you do not need to "Set Score Equal to 0" at scene start.

Displaying Score Text

By creating the score variable, Lightwell will be able to store the points for that player. However, we need to create a visual score counter for the player to see how many points he/she has. 

Add another action card and now we are going to Set and the score text layer that we've created for our scene. Under layer, look for the score text layer name and select the text property. By selecting the layer text property, we can now change the text to display whatever we want. 

In this example, I want the score text to display like Score: #. You can adjust the value in the Equal To section. Type in how you'd like the score text to display and then add the operator "+" to the score variable. 

The Score label's text value will now display [score text] + [score variable] on the scene i.e Score: #.

Testing Our Scoreboard

During our test, we are looking for the score text value to count and display the value every time we drag the circle to the box. 

Ta-da! This is a simple way to create player score for your game. 

Here's the complete interactions flow:

Did this answer your question?