# Remove

### Introduction

The Remove method is responsible for removing the argument object from the calling Layer. Remove has the following signatures:

```
Remove(Sprite spriteToRemove)

Remove(SpriteFrame spriteFrame)

Remove(Text textToRemove)

Remove(Scene scene)

Remove(IDrawableBatch batchToRemove)
```

### When to call Remove

Calling Remove is usually not necessary. The reason is because the internal list that Layers use to keep track of objects is a two-way list. In other words, consider the following code:

```
// Assuming layer is a valid Layer
Sprite sprite = new Sprite();
SpriteManager.AddToLayer(sprite, layer);
// At this point the Sprite is part of the Layer
SpriteManager.RemoveSprite(sprite);
// Now the Sprite is no longer part of the Layer
if(layer.Sprites.Count == 0)
{
  // This will be true
}
```

Therefore, you will not need to call Remove to take a Sprite off of a Layer if you are using the SpriteManager to remove it. However, Remove can be useful if you would like to move a Sprite from one Layer to another:

```
// Assuming that layer1 and layer2 are valid Layers:
// Assuming layer is a valid Layer
Sprite sprite = new Sprite();
SpriteManager.AddToLayer(sprite, layer1);
// At this point the Sprite is part of layer1
layer1.Remove(sprite);
SpriteManager.AddToLayer(sprite, layer2);
// Now the Sprite is no longer part of layer1, but it is a part of layer2
```


---

# 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/api/flatredball/graphics/layer/remove.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.
