Changing layouts with global objects remaining.

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm not sure if this has been discussed yet, but I'm betting it has. I notice if you change layouts, if the previous layout had global objects on it, then those will appear in the second layout. Is there some way to fix this, or is it another glitch?

  • I think global objects are global because they stay in any layout....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I usually make a layout solely for storing global objects. That could be one way of avoiding you problem maybe - store them in a layout the player will never see, and then create/destroy them on screen whenever they are needed?

    Maybe I am wrong and you need something completely different

  • I believe that is intentional.

  • That could work, but it'd be more of a hassle to do something like

    + System: Start of layout

    -> System: Create object on layer at (X, Y)

    for each and every object I want in the level, wouldn't it?

    And since you seem to have tested it, if you do something like

    Start Layout A

    Create global objects on Layout A that are stored on Layout C

    Go to Layout B

    The global objects that were created on Layout A wouldn't still remain when you go to Layout B, would they? I'd assume they'd behave just the same as normal global objects, even if pulled from another layout.

    [quote:3rc4hyz8]and then create/destroy them on screen whenever they are needed?

    Are you suggesting I delete them upon leaving the layout? Whether you were or not, that was an idea that just popped into my head that I was gonna try.

    In that case, having a seperate layout storing the global objects wouldn't be needed, would it? Just destroy all global objects on the event that tells the application to go to a new layout, right?

    [quote:3rc4hyz8]I believe that is intentional.

    But, wait, why would it be intentional? What benefit could that have? Right now, in my testing, I have a stage with all these global objects, which are items for the player to pick up. There's also an overworld map to select different stages. When I go to the overworld map, all the global objects from the previous layout show up on the overworld map, all in the exact same spots as they were on the previous layout.

    After messing around with this a bit, I wonder why I should mark some objects as being global at all. At first, I assumed it would be easier to bring objects to other layouts, but you still have to copy and paste them into other-- And now the message board is glitching up.

    You still have to copy and paste global objects into other layouts... Which makes me wonder why I should bother with marking them as "Global" in the first place. The only thing that really changes is that you can access those in other layout event sheets more easily. I guess the best reason would be to allow for levels that have doorways into other rooms. Have a player access a door, appear in another room, no need to copy and paste the player object where they would end up.

    I gotta stop editing this message now, because the glitchery is driving me insane.

  • Making an object global means it isn't deleted upon switching layouts at runtime and is listed in every layout's object list at edit time. That's it.

  • I gathered. ^^;; I'm gonna stop using them now, except when I find a conveinent fix with them, like that "doorway" thing I mentioned for player objects. I had originally assumed I would need to use global variables to keep track of player position when going through doors, or teleporters to other layouts, but perhaps a single global object for the player is enough.

    AH! ::brain processing:: AGH >_< Back when I discovered that I was getting two pieces of music from the AudioX object... I thought that was some special property of the AudioX object. It wasn't! It was because it was global! I had an AudioX object on each layout, so of course, two tracks of music were playing!

    The main benefit to global objects would be something like the Mouse and Keyboard object, or AudioX! Just put those on the first layout of your game, and you're done! AGH! Of course!

    And like I said, for stages that use more than one layout, using a global player object could be useful too. But other than that, most everything doesn't need to be a global object! I gotta turn that off for... EVERYTHING! Except MouseKeyboard and AudioX. And delete MouseKeyboard and AudioX on every other layout except the first one. AHH!

  • I am sorry for necroposting, but do global objects keep their private variable values upon changing layout?

  • Yep, everything about global objects is preserved with a layout change.

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