# LayerProvidedByContainer

### Introduction

The LayerProvidedByContainer property gives you access to the layer that the containing Screen or Entity has passed to this through Glue or through the AddToManagers method call. For more information on working with Layers in code, see the [Layer page](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).

### Usage

You can access the Layer simply by using the LayerProvidedByContainer property:

```
Layer layer = this.LayerProvidedByContainer;
// Do whatever with layer
```

The LayerProvidedByContainer can be used to add additional objects to the same Layer. The following code shows how to create a new Sprite using an existing entity's LayerProvidedByContainer:

```lang:c#
Sprite sprite = new Sprite();
SpriteManager.AddToLayer(sprite, this.LayerProvidedByContainer);
```

The following code shows how to create new entities using an existing entity's LayerProvidedByContainer:

```
int numberOfOtherEntitiesToCreate = 5;
for(int i = 0; i < numberOfOtherEntitiesToCreate; i++)
{
   EntityType childEntity = new EntityType(ContentManagerName, false);
   childEntity.AddToManagers(LayerProvidedByContainer);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flatredball.com/flatredball/glue-reference/entities/glue-reference-layerprovidedbycontainer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
