# Sprite Renderer

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component engine.SpriteRenderer
```

Draws a texture region at the node transform.

## From a script

Flash the sprite white when hit and mirror it to face the direction of travel.

```aes check
package player

script HitFlash {
    var Flash float = 0.1
    var timer float
    var base Color

    func Ready() {
        base = node.Get<SpriteRenderer>().Tint
    }

    func Hit() {
        node.Get<SpriteRenderer>().Tint = Color{1, 1, 1, 1}
        timer = Flash
    }

    func Face(dir float) {
        sr := node.Get<SpriteRenderer>()
        sr.FlipX = dir < 0
    }

    func Update(dt float) {
        if timer > 0 {
            timer -= dt
            if timer <= 0 {
                node.Get<SpriteRenderer>().Tint = base
            }
        }
    }
}
```

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Sprite | `Sprite` | `Texture` | `none` | Texture or atlas region to draw. Empty draws a solid rectangle in the tint color. |
| Material | `Material` | `AssetRef<material>` | `none` | Shared sprite-domain material. Per-node changes belong to MaterialOverride. |
| Layer | `Layer` | `int` | `0` | Sorting layer. Higher layers are drawn on top of lower ones. |
| Order | `Order` | `int` | `0` | Order inside the layer. Higher values are drawn later, on top. |
| Tint | `Tint` | `Color` | `rgba(1, 1, 1, 1)` | Color multiplied with the texture. Alpha controls transparency. |
| Origin | `Origin` | `Vec2` | `(0.5, 0.5)` | Pivot in normalized sprite space. (0.5, 0.5) is the center, (0, 0) the top-left corner. |
| Size | `Size` | `Vec2` | `(0, 0)` | Size in world units. Zero uses the texture size divided by the camera zoom. |
| Flip X | `FlipX` | `bool` | `false` | Mirrors the sprite horizontally. |
| Flip Y | `FlipY` | `bool` | `false` | Mirrors the sprite vertically. |
| Blend | `Blend` | `enum` | `premultiplied` | How the sprite blends with what is behind it: premultiplied alpha, opaque or additive. |
| Filter | `Filter` | `enum` | `nearest` | Texture sampling: nearest keeps pixel art sharp, linear smooths it. |
