How do I create new layers dynamically via events?

0 favourites
  • 5 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Hi! New here and relearning construct. I am trying to read a JSON file and represent it's values by 3D blocks. I intend to generate a level by stacking arrays to form a 3d environment out of blocks.

    I tried creating objects into a non-existing layer on runtime, assuming it will create a new layer, then increase the Z elevation of that layer later in the events. However, upon debugging, that wasn't the case as I found out that objects are still being created in the Layer 0(default).

    I did some googling and found some old forum posts from 3+ years ago saying that you can't do that in Construct. Is it still the limitation in present? I know I could just simply set z elevation of each objects in the event but I am still rooting on my initial approach.

    I am starting to feel at loss here.

    Tagged:

  • It's not supported. Frankly, during all my years working in Construct I never needed to create layers in runtime. Well, maybe once. But you can always create a bunch of spare layers in the editor and use them. Say, create 20 layers, name them L0, L1 etc.. And you can reference them by name - "L"&index

    But if you think you need this feature, you can vote for it here:

    construct23.ideas.aha.io/ideas/C23-I-72

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you. I guess I'll proceed with plan b and adjust my objects' z-elevation one by one... or is there a way to do this on bulk. just wondering.

  • You can use "For Each" loop to process all object instances, for example:

    For Each Sprite -> Sprite set Z Elevation to loopindex*10

    It's even possible without a loop:

    Sprite set Z Elevation to Self.zsort*10

    Where zsort is an instance variable on the sprite.

  • You can use "For Each" loop to process all object instances, for example:

    For Each Sprite -> Sprite set Z Elevation to loopindex*10

    It's even possible without a loop:

    Sprite set Z Elevation to Self.zsort*10

    Where zsort is an instance variable on the sprite.

    Awesome. I'll try this out. Thank you!

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