How do I control layers?

0 favourites
  • 10 posts
From the Asset Store
Create large maps with dynamic depth and precise sprite layering control in top-down games.
  • Hi, I'm having a problem where I have most of my main objects on layer 0, and I'd like to add a layer below that layer. This makes the new layer 0 and the old layer 1. Is there a way to have all of the events in my event sheet refer to the objects in their correct, new layer 1 instead of layer 0 in a way where I don't have to change each event by hand?

    Thanks!

  • Hi, I'm having a problem where I have most of my main objects on layer 0, and I'd like to add a layer below that layer. This makes the new layer 0 and the old layer 1. Is there a way to have all of the events in my event sheet refer to the objects in their correct, new layer 1 instead of layer 0 in a way where I don't have to change each event by hand?

    Thanks!

    Just curious, sanderstyler. How are you currently referring the objects in layer 0? I'm curious, because I haven't had any issues with objects residing in old layers after adding new layers nor after changing layer orders..

  • Hi, thanks for your reply.

    An example could be:

    On condition -> Create object on layer 0

    Whenever I add a layer below layer 0, the new layer becomes 0 and the old layer becomes 1. However, in the event sheet, the event still says

    On condition -> Create object on layer 0

    I'd like know if there's a way to make all of the events that refer to 0 start referring to 1 after I add the new layer

  • Hi, thanks for your reply.

    An example could be:

    On condition -> Create object on layer 0

    Whenever I add a layer below layer 0, the new layer becomes 0 and the old layer becomes 1. However, in the event sheet, the event still says

    On condition -> Create object on layer 0

    I'd like know if there's a way to make all of the events that refer to 0 start referring to 1 after I add the new layer

    Thank you for the update, sanderstyler.

    The layer name should stay the same. I have just tested and confirmed.

    Case study

    1. Create a new sprite object named 'Player'.

    2. Create a new layer named 'Layer 1'.

    3. Go to Event Sheet and create a new event [System] -> [On Start of Layout].

    4. Under [On Start of Layout], create [System] -> [Create Object] -> pick [Player] sprite and create it on [Layer 0].

    5. Move Layer 1 under Layer 0.

    6. Notice the layer names don't change and the event sheet still says [Create Object] [Player] [On Layer 0].

    You can also change the layer name to something else. Click the [Layer 0] and press [F2] on your keyboard to change the layer name to another name and see if that name would change after adding a new layer and put that layer underneath. It won't change.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, sanderstyler's right, it doesn't work, I'm working around by storing the game layer in a variable, and just referring to that every time, that way, no matter how many layers I add, I just can just update the variable.

  • Instead of referring to the layer number in your events, refer to the layer name.

    The number changes based on order, the name doesn't.

  • Instead of referring to the layer number in your events, refer to the layer name.

    The number changes based on order, the name doesn't.

    So in the "layer" box in he create object dialog I just type the layer name? What if it conflicts with a variable or a system expression?

  • This is addressed in the manual. https://www.scirra.com/manual/42/layers-bar

    [quote:1fffye9k]A number to the right. This is a zero based index of the layer (the first layer is number 0, not 1). If you need to enter a layer number in the event system, this is the corresponding number. (You can also enter layer names in the event system which might be more convenient if you regularly reorder layers.)

    Some quick experimentation reveals that to refer to a layer by name, you would use quotation marks, while a variable or other expression with the same name can be referenced without quotation marks.

  • This is addressed in the manual. https://www.scirra.com/manual/42/layers-bar

    [quote:1yvm6ebu]A number to the right. This is a zero based index of the layer (the first layer is number 0, not 1). If you need to enter a layer number in the event system, this is the corresponding number. (You can also enter layer names in the event system which might be more convenient if you regularly reorder layers.)

    Some quick experimentation reveals that to refer to a layer by name, you would use quotation marks, while a variable or other expression with the same name can be referenced without quotation marks.

    Thanks, it wasn't immediately obvious, now I know.

  • Ashley maybe it could be worth considering changing the layer field default for the System-Create Object action (and others?) to be the name "Layer 0" rather than 0?

    It would help in the situation where a user does significant work on their project, then decides to add a background or other layer beneath the initial one. Currently they would have to go back through all their events that created objects and update the layer field for each.

    The second benefit would be for those who don't realize you can use layer names to reference the layer at all, as it really isn't immediately obvious.

    I can't currently think of any situation where using the layer index would be preferable to the layer name.

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