Simple way to make a composite GUI

0 favourites
  • 2 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello, I want to make a GUI from a mixture of elements, mostly 9patch's. I want to have functions which assemble the GUI from its parts. I have done this, however, when removing the GUI I currently have to loop through all instances of the components and remove them. This method would break if I were to have two panels open simultaneously and only wish to close one; this is not currently a problem and I don't foresee it occurring in my current game, however it is still a flaw of the method. I am now trying to simply remove all of the objects without the loop. The containing method would work if it were possible to have conditional containers for instances instead of the containers currently available. I could, in an OOPL create an array of classes for sub components within the main panel class, however, that's not the case for C2; unless you can somehow define an object as a child of another.

    What is the best solution for the problem? Will I just have to stick with the loop?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there are 2 ways that I have used

    you can add a variable to your objects (for example USAGE) and give it a value for each of your layouts or sub-layouts in your GUI. Then when you are running through your objects, only destroy those with the right value in the variable. It's pretty efficient.

    the second mode is to use containers. all the parts of the gui construct are loaded at the same time and destroyed at the same time. load one, get them all, destroy one, destroy them all. it's a bit messy if you have multiple gui structures using the same objects, but it is a very quick way to build or destroy a multi-object combination.

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