[Suggestion] Create layers at runtime.

Discussion and feedback on Construct 2

Post » Thu Aug 28, 2014 2:51 am

I'm working on a project with a lot of layouts, and most of those layouts share certain elements (like the UI). I use events to create all of the objects for those elements (so that changes are reflected everywhere), and I give them their own layer for organization. However, sometimes I need to make a change or add a feature that requires a layer to be added or modified. Currently I have to go through each layout manually, and make the change. This is very tedious and boring. If I could create that layer at runtime (like the objects that populate it), I could avoid such mindless tasks.

It would also be useful for games with level editors, as some levels may need more layers than others.
B
54
S
19
G
13
Posts: 97
Reputation: 10,146

Post » Thu Aug 28, 2014 6:42 am

You could do this easily by having separate Event Sheets that create, for instance, the HUD on each start of Layout.

You just then include the relevant Event Sheets to whichever Layout requires them, with the added bonus that they can be modified in one single place.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,415
Reputation: 59,516

Post » Thu Aug 28, 2014 6:55 am

What zenox98 said. Its the easiest.
And a trick I use is to actually build the layout(1 instance of it) and I create a button to grab all the co-ordinates of objects and put into array, and download. Copy / paste that json file over existing one in projects folder.
include Event sheet to build layer that uses the object1x,objecty from array whenever needed.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Thu Aug 28, 2014 2:43 pm

I would like to be able to select all layouts, for example, and then edit their layers and other properties, as a group / in one go.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,228
Reputation: 44,888

Post » Thu Aug 28, 2014 10:37 pm

@zenox98
@DUTOIT

It seems both of you missed the part where I mentioned that I'm already creating the objects via events. I want to create the layers as well as the objects via events.
B
54
S
19
G
13
Posts: 97
Reputation: 10,146

Post » Thu Aug 28, 2014 11:10 pm

It's not possible to create new layers at runtime to my knowledge.
I don't really see why you'd need to create new layers at runtime though, could you give a concrete example? If you'll need an extra layer for a layout and have the logic to populate the layer why not just add an empty layer in the editor and do what ever you want with it at runtime?
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Fri Aug 29, 2014 12:17 am

@KFC

That's what I currently do. But there have been occasions where I've needed to change the properties of a layer (or add a new one) to a non-trivial amount of layouts. Most recently, I changed how transitioning to/from solid colors worked so that it didn't require webgl, and I needed to add a layer to about 100 layouts, as well as remove the webgl effect from those layouts. It would have been far simpler to just create the layer from events, so I don't have to do that repetitive work. Why do repetitive work when the computer should be able to do it?

Additionally, if you have a game with a level editor, a user may want to make a level with more parallax backgrounds than you have layers in the layout that loads the levels.
B
54
S
19
G
13
Posts: 97
Reputation: 10,146

Post » Fri Aug 29, 2014 8:54 am

I totally understand what you mean.
In both scenarios you listed, (Making a change to a layer means going to every layout and making the same layer change, and level editor layer stuff) I have had to deal with as well.
It's like a matter of pre-planning what layers you would want and what settings/effects you want, make it in one layout, then duplicate that layout. But you best hope you don't want to tweak a single setting in a layer, because then you'll need to fly across every single layout to manually make the change (or possibly edit the project's files to apply the change quicker which is risky and a bad idea in general to tinker with things like that).
The ability to add layers at runtime sounds like a dream, we could then have 100 layouts, decide "Hmm, I want a HUD layer" (if you somehow didn't think to add a HUD to your game after making 100 layouts lol), make an event "Create layer : HUD" (probably have an index for where to z-order the layer), and then all other events already exist to tweak the settings of layers (minus a few, like adding new effects). Would be awesome.

tl;dr: I agree! +1
B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Fri Aug 29, 2014 9:06 am

Oh, sorry I miss understood. Agree it would be neat to add a layer to a layout on runtime.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Fri Aug 29, 2014 9:20 am

Big +1 here as well, this would be a great time saver. Would use that for pretty much every project ;).
B
79
S
22
G
4
Posts: 311
Reputation: 12,774


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests