Remember values of instance variables

2

Index

Stats

8,010 visits, 16,691 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 16 Feb, 2012. Last updated 19 Feb, 2019

A few words about instance variables before we start. In the picture below I’ve marked with red where you can see some “built in” instance variables for a "TextBox". There are a few more in the background e.g. UID, but we don’t need those for this tutorial. All elements you see “on the stage” are instances of the same "Text box"-object. The second "TextBox"-instance on the picture has different values at the instancevariable Y (- its below the current active instance-) and the instancevariable Text (- value is test2). In this tutorial I’ll only use the built in instancevariables – the work with your own instance variables (marked green in the picture) is quite similar.

At first create three objects: TextBox, Text and a Button

I’ve changed the “Text-Properties” of the Text-object in “Number of active Layout” and of the Button to “next Layout”.

Let’s go on. Duplicate the “Layout 1” via the right mousebutton and link the "Event sheet 1" to the “Layout 2”:

When you click twice on “Layout 2“ on the right side of Construct2 then the second Layout should open in Construct2. (Via drag’n’drop you can order the Layouts.)

The second Layout looks similar to the first ;)

Ok make some funny events: Switch to the Event sheet 1 and create the following event:

When you make a preview you’ll see this works but you wouldn’t see anything changing. It would be nice when we see which layout is active. For that reason we create a global variable “activeLayout” and init it with the number 1. Click anywhere in the eventsheet with the rightmouse:

  • 3 Comments

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