Sprite Renderer
Draws a texture region at the node transform.
component engine.SpriteRenderer
Usage
Add it with Create → Rendering → Sprite.
Art Studio
Try it
Sprite draw order
The blue sprite overlaps a red sprite. Order controls which one is in front.
Change Order from 1 to -1, then use Reset to restore it.
Scene3 nodes
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Sprite | Texture | none | Texture or atlas region to draw. Empty draws a solid rectangle in the tint color. |
| Material | AssetRef<material> | none | Shared sprite-domain material. Per-node changes belong to MaterialOverride. |
| Layer | int | 0 | Sorting layer. Higher layers are drawn on top of lower ones. |
| Order | int | 0 | Order inside the layer. Higher values are drawn later, on top. |
| Tint | Color | rgba(1, 1, 1, 1) | Color multiplied with the texture. Alpha controls transparency. |
| 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 | Vec2 | (0, 0) | Size in world units. Zero uses the texture size divided by the camera zoom. |
| Flip X | bool | false | Mirrors the sprite horizontally. |
| Flip Y | bool | false | Mirrors the sprite vertically. |
| Blend | enum | premultiplied | How the sprite blends with what is behind it: premultiplied alpha, opaque or additive. one of: premultiplied, opaque, additive |
| Filter | enum | nearest | Texture sampling: nearest keeps pixel art sharp, linear smooths it. one of: nearest, linear |
From a script
Flash the sprite white when hit and mirror it to face the direction of travel.
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
}
}
}
}
Related guides
- Materials and shaders A material is a shared asset.
- Sprites SpriteRenderer draws a texture region at the node's 2D transform.
- Art Studio: drawing, frames and source files Create a drawing, edit layers and frames, then distinguish saving its source from publishing game assets.