Simple way to make a composite GUI

Get help using Construct 2

Post » Tue Jun 09, 2015 6:13 pm

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?
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Tue Jun 09, 2015 8:31 pm

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.
B
7
S
3
G
1
Posts: 184
Reputation: 1,352


Return to How do I....?

Who is online

Users browsing this forum: MrSkailo and 23 guests