[Suggestion] Create layers at runtime.

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

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

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

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

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

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

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

  • 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

  • Oh, sorry I miss understood. Agree it would be neat to add a layer to a layout on runtime.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Big +1 here as well, this would be a great time saver. Would use that for pretty much every project .

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