> For the complete documentation index, see [llms.txt](https://cavonstavants-organization.gitbook.io/rtype-technical-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavonstavants-organization.gitbook.io/rtype-technical-documentation/index_classes/classanim_1_1_animation.md).

# anim::Animation

[Animation](/rtype-technical-documentation/index_classes/classanim_1_1_animation.md) class should be used to create an animation in sfml. [More...](#detailed-description)

`#include <Animation.hpp>`

## Public Functions

|                            | Name                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                            | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-animation"><strong>Animation</strong></a>()<br>Create a new instance of <a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md">Animation</a>.</p>                                 |
|                            | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-~animation"><strong>\~Animation</strong></a>() =default<br>Destroy the instance of <a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md">Animation</a>. It's set to default.</p> |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-update"><strong>update</strong></a>()<br>It updates the texture used depending on the duration time and the previous index in the vector of texture.</p>                                                                                                |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-addtexture"><strong>addTexture</strong></a>(const std::string & texturePath, const sf::Vector2f & position, const sf::Vector2f & size)<br>It adds a texture on the vector of texture used for the animation.</p>                                        |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-addtexture"><strong>addTexture</strong></a>(const sf::Image & image, const sf::Vector2f & position, const sf::Vector2f & size)<br>It adds a texture on the vector of texture used for the animation.</p>                                                |
| const sf::RectangleShape & | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getshape"><strong>getShape</strong></a>() const<br>It returns the shape of the animation with the correct texture.</p>                                                                                                                                  |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-moveshape"><strong>moveShape</strong></a>(const sf::Vector2f & move)<br>It move the shape of the animation with the vector2f move.</p>                                                                                                                  |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-setduration"><strong>setDuration</strong></a>(const std::size\_t & duration)<br>It sets the duration between each frame of the animation.</p>                                                                                                           |
| const std::size\_t &       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getduration"><strong>getDuration</strong></a>() const<br>It gets the duration between each frame of the animation.</p>                                                                                                                                  |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-setposition"><strong>setPosition</strong></a>(const sf::Vector2f & position)<br>It sets the position of the shape used for the animation.</p>                                                                                                           |
| const sf::Vector2f &       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getposition"><strong>getPosition</strong></a>() const<br>It gets the position of the shape used for the animation.</p>                                                                                                                                  |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-setsize"><strong>setSize</strong></a>(const sf::Vector2f & size)<br>It sets the size of the shape used for the animation.</p>                                                                                                                           |
| const sf::Vector2f &       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getsize"><strong>getSize</strong></a>() const<br>It gets the size of the shape used for the animation.</p>                                                                                                                                              |
| const sf::FloatRect        | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getglobalbounds"><strong>getGlobalBounds</strong></a>()<br>It gets the size of the shape used for the animation.</p>                                                                                                                                    |
| void                       | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-setcolor"><strong>setColor</strong></a>(const sf::Color & color)<br>It sets the color of the shape used for the animation.</p>                                                                                                                          |
| const sf::Color &          | <p><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md#function-getcolor"><strong>getColor</strong></a>() const<br>It gets the color of the shape used for the animation.</p>                                                                                                                                           |

## Detailed Description

```cpp
class anim::Animation;
```

[Animation](/rtype-technical-documentation/index_classes/classanim_1_1_animation.md) class should be used to create an animation in sfml.

**Note**: It contains a vector of texture that will be updated, depending on a duration time, with the function update. You should define a duration between each frame. You should define a position for the animation. You should define a size for the animation. You should add a texture for the animation.

**Warning**: A texture is always add at the end of the vector of texture.

## Public Functions Documentation

### function Animation

```cpp
Animation()
```

Create a new instance of [Animation](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md).

### function \~Animation

```cpp
~Animation() =default
```

Destroy the instance of [Animation](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classanim_1_1_animation.md). It's set to default.

### function update

```cpp
void update()
```

It updates the texture used depending on the duration time and the previous index in the vector of texture.

### function addTexture

```cpp
void addTexture(
    const std::string & texturePath,
    const sf::Vector2f & position,
    const sf::Vector2f & size
)
```

It adds a texture on the vector of texture used for the animation.

**Parameters**:

* **texturePath** The path to load the texture from.
* **position** The position from which the texture of the loaded image is to be obtained.
* **size** The size to get the texture from in the image loaded.

**Exceptions**:

* **AnimationException** will be thrown if the image cannot be loaded.

**Warning**: Be carful, the texture is added at the end of the vector. Please add texture in the correct order.

### function addTexture

```cpp
void addTexture(
    const sf::Image & image,
    const sf::Vector2f & position,
    const sf::Vector2f & size
)
```

It adds a texture on the vector of texture used for the animation.

**Parameters**:

* **image** The image used to create the texture from.
* **position** The position from which the texture of the loaded image is to be obtained.
* **size** The size to get the texture from in the image loaded.

**Exceptions**:

* **AnimationException** will be thrown if the texture cannot be created.

**Warning**: Be carful, the texture is added at the end of the vector. Please add texture in the correct order.

### function getShape

```cpp
const sf::RectangleShape & getShape() const
```

It returns the shape of the animation with the correct texture.

**Return**: const sf::RectangleShape reference of the shape.

**Note**: Use this function to get the shape to be drawn.

**Warning**: Keep in mind that you need to update the texture with the `update` function.

### function moveShape

```cpp
void moveShape(
    const sf::Vector2f & move
)
```

It move the shape of the animation with the vector2f move.

**Note**: Use this function to move the shape.

**Warning**: Keep in mind that you need to draw the shape again.

### function setDuration

```cpp
void setDuration(
    const std::size_t & duration
)
```

It sets the duration between each frame of the animation.

**Parameters**:

* **duration** The duration between each frame of the animation as millisecond.

**Note**: The animation must be set as millisecond.

### function getDuration

```cpp
const std::size_t & getDuration() const
```

It gets the duration between each frame of the animation.

**Return**: const std::size\_t reference of the duration.

### function setPosition

```cpp
void setPosition(
    const sf::Vector2f & position
)
```

It sets the position of the shape used for the animation.

**Parameters**:

* **position** The position to be set on the shape.

### function getPosition

```cpp
const sf::Vector2f & getPosition() const
```

It gets the position of the shape used for the animation.

**Return**: const sf::Vector2f reference of the position.

### function setSize

```cpp
void setSize(
    const sf::Vector2f & size
)
```

It sets the size of the shape used for the animation.

**Parameters**:

* **size** The size to be set on the shape.

### function getSize

```cpp
const sf::Vector2f & getSize() const
```

It gets the size of the shape used for the animation.

**Return**: const sf::Vector2f reference of the size.

### function getGlobalBounds

```cpp
const sf::FloatRect getGlobalBounds()
```

It gets the size of the shape used for the animation.

**Return**: const sf::Vector2f reference of the size.

### function setColor

```cpp
void setColor(
    const sf::Color & color
)
```

It sets the color of the shape used for the animation.

**Parameters**:

* **color** The color to be set on the shape.

### function getColor

```cpp
const sf::Color & getColor() const
```

It gets the color of the shape used for the animation.

**Return**: const sf::Color reference of the size.

***

Updated on 2022-11-13 at 17:21:37 +0100


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://cavonstavants-organization.gitbook.io/rtype-technical-documentation/index_classes/classanim_1_1_animation.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.
