Best Way to use Global Objects for Custom GUI?

For questions about using Classic.

Post » Mon Dec 06, 2010 1:51 am

I've got a Q,

I'm making my own GUI, which will have things like slide bars and buttons etc. So a fare amount of code is needed to make them work. I was thinking I could do it with global objects and include an event sheet. BUT, they seem to carry over between layouts and if I destroy at the end of a layout they don't get re-created (I have an event to create them at start of layout in the right position.)

If i made myself clear, does anybody have any tips or a better idea?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Mon Dec 06, 2010 2:39 am

If your going to create, and destroy them for each layout, then don't use global.
That's probably a better way to go anyway, especially if you resize anything.

Global simply means keep that objects state from the previous layout.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Mon Dec 06, 2010 3:10 am

Yeah, but I don't want to DESTROY them, I just have to or they carry to whatever other layouts you go to. And the reason I wanted to use global, is to keep down on the number of object. Otherwise I'd need a button object for the options layout, the store layout, etc. with a lot of GUI elements it'd get messy doing it that way.

And this is a big project so I'd like to keep it as clean as possible.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Mon Dec 06, 2010 3:34 am

Try using an inheritance layer (in the layer's properties). From the wiki:

Every layer has a property titled 'Inheritance Layer'. Using this property, it is possible to display the content's of another layer - even from a different layouts! Just specify the (unique!) name of the layer you would like to 'inherit', and Construct will search for that layer in the entire application. This is very practical to make things like HUDs appear in multiple layouts without having to copy their containing objects.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon Dec 06, 2010 7:46 am

Yes, inheritance layer is the way to go. Also a separate event sheet for the UI events (don't forget to include it!).
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Dec 06, 2010 2:45 pm

So, I'm trying an Inheritance layer and game it a unique name and put that name in the field for another layer in another layout and nothing?

Is there some trick?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Mon Dec 06, 2010 3:07 pm

Not really. Try it in a blank cap, and make sure the layer name is unique and spelled correctly and is visible. If you've entered it correctly, it should appear after entering the name in the inheritance layer field and pressing enter.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon Dec 06, 2010 3:14 pm

Whoops!

I put the object in the wrong layer.

I feel silly.

Thanks! I'll get to work on this now.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests