Declaring variables
If you want to store any kind of data in variables, you have to declare them first. In the backend of Construct 2, there are a lot of variables that are already declared for you. This means that Construct 2 takes out the work of declaring variables. The variables that are taken care of for you include the following:
- Keyboard
- Mouse position
- Mouse angle
- Type of web browser
Writing variables in code
When we use Construct 2, a lot of the backend busywork has already been done for us. So, how do we declare variables in code? Usually, variables are declared at the top of the coding document, as shown in the following code:
Int score; Real timescale = 1.2; Bool isDead; Bool isShooting = false; String name = "John Bura";
Let's take a look at all of them. The type of variable is listed first. In this case, we have the Int
, Real
, Bool
(Boolean), and String
variables. Next, we have the name of the variable. If you look carefully, you can see that certain variables have an...