Stop C2 checking global variables on new layout

0 favourites
  • 10 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.
  • Everytime I go to another layout while having an event such as:

    If GlobalVariable1 = 0)

    Destroy the world

    Every time the layout switches, it rechecks to see if this variable is 0 (and if it is, it destroys the world...again). Is there a way to avoid something like this?

  • Have all the layouts the same Event Sheet? Take a look to the layout properties. "Event Sheet". If so, check on what layout you are.

  • on end of layout reset global variables


    on end of layout set "globalvariable1"=1

  • DAG Yes - all of my layouts are using a "Main" event sheet, and then subsequent event sheets for the specifics levels.

    Roccinio - the thing is, I don't want the global variable to change. It widely affects other events, and switching it to 1 when changing the layout will ultimately re-trigger the event anyway when switching it back to 0.

  • then you are doing it wrong,there is a reason they are called global,

    try this.

    create one event sheet for each level you have.

    copy paste all events to all the event sheets you have.

    Do not include one event sheet to another.

    lets say you have 100 levels

    set global variable "level" to 0

    when you finish a level

    on end of layout "level 1 "set "level:=1

    on end of layout "level 2 "set "level:=2

    on start of layout "level 2" "level"=1 destroy "level 1"

    on start of layout "level"=3 "level"=2 destroy "level 2"


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Roccinio - the reason I don't want to do that is if I want to change something that happens in all 100 of those levels, I would have to change the event 100 times...for each time I wanted to change it (sometimes I can't make up my mind!)

  • You may want to rethink how you are approaching it if you don't want things to work they way they were designed to. I want my car to fly. But we don't make flying cars. But I want it to. You could possibly create another global variable that is either true or false, and add a condition that checks for it with your end of layout condition. So you say if end of layout and superVariable = 1, then blow up the world, that way you can set superVariable however you want in the layouts that should not blow up.

  • BluePhaze,

    I'm sorry, but it seems incredibly silly to make something like a menu or interactive controls that will be used on every layout, and instead of using #Includes, copy/paste the events to 100+ event sheets.

  • If you want to get around global variables being global you are going to have to have something that is different on the ones that you don't want it happening on. That is just the way it is. If they are all the same with the same logic, you don't have a way to differentiate.

  • It's really not that hard. I have used an invisible object with an instance variable before. I drop and instance of it in each layout and set the instance variable accordingly. My events use it. Not hard. It's not unheard of to think that if you have 100 different layouts and you don't want to key off their names (which are unique and would work also) then you are going to have to make something different in each one. Your events in your "global" event sheet just needs to take that into account. Using the method I mentioned already doesn't really add much to the complexity or effort when building layouts. It is as simple as dropping an object (which you are already doing on each layout) in and setting a variable on it. Trying to do it after the fact may be a pain but that is just poor planning and not a deficiency in the way the tools work.

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