Best Way to use Global Objects for Custom GUI?

This forum is currently in read-only mode.
  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • Yes, inheritance layer is the way to go. Also a separate event sheet for the UI events (don't forget to include it!).

  • 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?

  • 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.

  • Whoops!

    I put the object in the wrong layer.

    I feel silly.

    Thanks! I'll get to work on this now.

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