How do I make a value constant across all layouts?

0 favourites
  • 5 posts
  • Hi, I'm a bit new to Construct 3, so this might be really basic.

    I've been trying to make a value(s) that stay constant across all layouts.

    To give context:

    Imagine you add a value to keep score, and add a text box to display the score. Well, I'm trying to make the score remain constant across all layouts, so that the score can be added to and subtracted from in all layouts. So if the value is set at 10 when exiting a layout, it will remain 10 on the start of the next layout.

    Sorry if this is a stupid question, but I've tried different things and I can't get it to work. Thank you.

  • Sounds like you want a global static variable.

    Create a variable in a global scope (not inside event or group)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You would use a global variable for this. You can right click on the event sheet and add it. It retains its value between layouts.

  • Thank you for the answers.

    I've managed to pretty much fix the problem. I was putting the Global Variable in the wrong Event Sheet. I put it on the games title layout, so being global, stays present on all other layouts. The text counter is working now, and is recording the score. Although the counter disappears on some layouts, but I think that's a separate problem, so probably will be easier to fix.

    I'll update if something else goes wrong.

    Thanks again for the help!

  • Good to hear the global variable is working for you.

    About the text disappearing in some layouts, I have no clue. Maybe it’s not added to the layout, or perhaps it's set to an empty text.

    You can run the game in debug preview mode and see if the text object is created. If created, it will be in the list of objects In the layout. Then you can inspect it and see if it has a text value.

    Debug preview is one of the options in the dropdown shown when holding the play button in the top bar In the editor.

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