Assigning instance variables to global values

0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi There,

    I have a series of buttons that allow the user to switch between layers. I store the target layer numbers in instance variables on the buttons.

    Sometimes, I also switch between layers through events.

    I would like to store the layer numbers in global variables like "GAMEOVER_LAYER = 1", instead of just using the raw layers numbers all over the code.

    However, I don't understand how to set my button instance variables to be equal to the global variables I've created. When i type the name of the global variable into the instance variable assignment box, when I hit enter, it resets the value to 0. Do I need to use some kind of prefix on the variable name? Is it even possible?

    Thanks,

    Peter

  • On start of layout (or something completly different) - > Set instance variable to global variable.

    You can't type variable names to other variables in the editor. It most be done via events.

  • Peter, you can set an instance variable in an action. When you create the action, select your button object, then the Set value action. In the Value field, enter your global variable name.

    You can also choose the global variable from the Object with expressions window, under the System object.

    Edit: ninja'd

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)