Changing layouts with global objects remaining.

For questions about using Classic.

Post » Tue Jan 11, 2011 10:26 am

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?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Tue Jan 11, 2011 10:45 am

I think global objects are global because they stay in any layout....
B
2
G
2
Posts: 15
Reputation: 680

Post » Tue Jan 11, 2011 11:16 am

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 :P
B
10
S
3
G
3
Posts: 110
Reputation: 2,206

Post » Tue Jan 11, 2011 10:27 pm

I believe that is intentional.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Tue Jan 11, 2011 10:35 pm

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?[/quote:3rc4hyz8]

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.[/quote:3rc4hyz8]

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.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Tue Jan 11, 2011 11:09 pm

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.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Tue Jan 11, 2011 11:17 pm

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!
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Thu Oct 27, 2011 7:02 am

I am sorry for necroposting, but do global objects keep their private variable values upon changing layout?
B
2
G
1
Posts: 6
Reputation: 462

Post » Thu Oct 27, 2011 7:14 pm

Yep, everything about global objects is preserved with a layout change.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests