How to Learn Construct 3? Next Steps for Beginners

52

Index

Contributors

Stats

76,102 visits, 276,350 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 1 Mar, 2019.

Instance variables example

The instance variables example displays the usage of instance variables.

Have a look at the explanation in the layout as well as the event sheet.

You can press F5 to preview the project in your browser and execute it as if it was exported.

In Construct you start by adding an object type to your project (for example a Sprite).

Then you can create instances of this object type during edit time or even during the execution of the game.

The object type may hold variables, which can hold a number, some text, or a boolean (on/off flag) for individual instances. These are instance variables.

Instance variables are common to all instances of an object type.

The object type is Sprite, we have 5 instances of this object type in our layout. Sprite has an instance variable named “ClickCount”.

All the instances of Sprite do have this instance variable.

Each instance of Sprite has its own value in “ClickCount”.

There is also a Text object type that has 5 instances, placed on top of each instance of Sprite.

If you click three times on the Sprite instance on the left, it will display “3” in the associated Text instance on top it.

This works because there are as many instances of Text as there are of Sprite and they were created and positioned in the same order.

Our first instance of Sprite holds the value “3” whereas all the other instances, at this time hold the value “0”.

In this case, the instance variable is a numeric value (actual numbers that can be used in maths operations).

Variables can also hold text values - also known as a “character string”.

Strings can contain numbers, but unlike numeric values, those are considered as characters, as text, and cannot be used as is in an operation.

The last type of value for a variable is boolean. The value is either True or False.

In that case “True” or “False” are not text like character strings but are known as reserved keywords.

Next Tutorial In Course

How to make a platformer game 47:07

An alternative to the Beginner's Guide, this tutorial helps you build your first platformer!

  • 17 Comments

  • Order by
Want to leave a comment? Login or Register an account!