Global Layer Oversight?

Discussion and feedback on Construct 2

Post » Thu Nov 20, 2014 6:30 am

Hey all,

Personally I'm thinking this an oversight but I'm curious to see what @ashley and others think. But, I must say having global layers is a complete joy! Thanks for implementing them.

I'm trying to dynamically turn off/on effects on a Global Layers but I found out there isn't an expression that lets you get a layer's index by passing in it's name. It think this is much more important now that we have Global Layers. With Global Layers we may have the same layer names, but they could be in a completely different order on each layout. Without being able to get the layer's index at runtime it invalidates some of the dynamic nature of Global Layers.

What I'm proposing is an expression as follows: GetLayerIndex(String layerName).
Description: "Get the current index of the layer with the name that was passed into the function. If the layer with that name does not exist the expressions returns null( or -1).

Image

Thanks!

p.s. I think I could write a plugin that would provide me this but I really feel like this should be an engine feature.
B
51
S
13
G
7
Posts: 146
Reputation: 6,773

Post » Thu Nov 20, 2014 8:58 am

Makes sense. Seems simple enough. +1
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Thu Nov 20, 2014 9:02 am

Yeah, I agree, +1.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Thu Nov 20, 2014 2:14 pm

What do you need it for? You can just type in the layer name right there where the arrow is already pointing to. Every layer parameter in Construct 2 accepts either a number for the index or a string for the name.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,852

Post » Thu Nov 20, 2014 2:23 pm

Is the global layers feature only available in beta at the moment?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Thu Nov 20, 2014 3:33 pm

@Ashley
:) I was about to ask for the same expression. My use case is I have multiple layers that I need to insert sprites by relative layer order, at runtime. My first inclination was to use "the" expression to convert the top layer name to it's number and then I can reference the lower layers by a relative index. There was no expression though, so I have to keep track of the top layer number and remember to change it as I add layers below the layer range I need to address relatively.

Seems like it should be a trivial expression to add. Thanks.
ImageImageImage
B
71
S
21
G
233
Posts: 3,697
Reputation: 130,370

Post » Thu Nov 20, 2014 3:51 pm

I'm still not clear why you need to do that - where in C2 do you need a layer index and can't use the layer name?
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,852

Post » Thu Nov 20, 2014 5:44 pm

I'm mapping data to layers. I'm doing a step-sequencer where different instruments are on different layers. The data is stored by index, so Voice0, Voice1, etc. I am hoping to support a standard input format with this format. When I load the data in, I load from the top layer, which I know the name of, and wanted to address subsequent layers relative to that one layer.

Obviously there are many ways to do this, but the most instinctive one was to only need to know the Name of that top layer, ask for it's number (as it may change as I develop the game), and then add the data layer by layer relative to that first layer.

I'm not saying there are many ways to work around this, but the most obvious one was to just know about that first Name, and then address everything relative to the layers Number. Retrieving the layers number at runtime seems the obvious choice,
ImageImageImage
B
71
S
21
G
233
Posts: 3,697
Reputation: 130,370


Return to Construct 2 General

Who is online

Users browsing this forum: newt and 5 guests