Create / Delete Layer using code? - NOT in editor

  • Hi All,

    Just to be clear, I'm not talking about the Editor.

    Is it possible to Create a layer + "Layer Name" and Remove/Delete it using Code?

    If possible, can someone please share an example file or screenshot to see how it's done?

    Thanks ahead!

    Tagged:

  • Iirc it's not possible. What are you trying to do? Showing/Hiding it should be sufficient.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Iirc it's not possible. What are you trying to do? Showing/Hiding it should be sufficient.

    No, showing and hiding is simple.

    My project is a creation toolset, I need to let my users to CREATE / USE / DELETE their own layers.

  • They would need to come up with rules for what happens when that happens.

    Like what happens to any objects on that layer, etc.

    A minefield waiting to happen.

  • Create a bunch of layers, name them like User01-User20, only the first of them visible by default. When user wants to "create" a new layer, make the next of these layers visible.

    Deleting, inserting and moving layers is a more difficult task. For example, if layer 3 is removed, you need to move all objects from layers User04-User20 to one layer down..

  • My alternative idea was similar to this, creating a "ready to use" layers and play with them.

    or an easier approach to do just limit my users to X layers, I'm considering this because it could work and hopefully won't be hard to code as well.

    Thanks for the advice everyone! :)

  • I see. I remember someone on the construct community discord was tinkering around with this idea, I don´t remember who it was though. I think it could´ve been Skymen.

    But your best bet is actually limiting the amount of layers and handling it like dop2000 suggested. I don´t know what you intend to let people create with it but there is likely an upper limit of layers that a user actually requires.

    It may be possible to create some sort of rudimentary layer system with the z-order of objects. Create a Sprite that acts as a "Layer" and use the Z-Order action to "Move to object > in front" to move it on that "Layer".

  • Yes, what dop suggested is more like what I'll probably go for a "ready to use X number of Layers".

    It should do the job.

    My current code is based on controlling the Z-Order of the current layer, Basically: one layer of instances have 3 the default Z-Order: Top, Mid, Bottom I'm not using all the manual numbers for unlimited Z-Order since it also change their scale based on the camera), so what I may do is each layer + default 3 Z-Order (Top, Mid, Bottom).

    So 1 layer basically is not enough once there are plenty of other objects, (I just tried it, it's a mess) so I want to give the user some extra layers to have more control this is why I think I should add layers for the created instances.

    I'm didn't decide how to approach the control of each instance specifically yet because currently if the mouse cursor is OVER an instance, it picks the top one and using SCROLL DOWN I sent it down on the Z-Order of the current layer, SCROLL UP sent it to TOP... moving them to other layers I should also let the user KNOW on which layer it is, so I'll probably need to design a "VISUAL" layer icons, that was my original idea but please share your thoughts.

    I'm not sure if I can make it or not, because it could be complex for my level but I'll try to play with it soon and see for myself, I'm very hyped to try it already... I hope it's not too complicated.

    One thing is sure, I ALWAYS naming my Layers, I never use the numbers... so I can follow them on the code easily (and I already have plenty of layers for the core software).

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