Ara
Download

Search or run a command

Jump to a section or open an Ara link.

Component · twoD

Sprite

A batched sprite with optional normal-mapped 2D illumination.

Fields

atlas

option<asset>
Atlas asset reference, resolved to a resident texture at extraction.
default null

region

string
Stable region name in the atlas.
default ""

normalAtlas

option<asset>
Optional normal atlas, using the same rectangles.
default null

size

vec2
Desired world size in metres; zero selects source size / pixels per metre.
default [0,0]

tint

vec4
Linear, straight-alpha tint.
default [1,1,1,1]

sortingLayer

i32
Painter's sorting layer; lower draws first.
default 0

order

i32
Painter's order within a layer; stable identity breaks ties.
default 0

flipX

bool
Mirror horizontally about the pivot.
default false

flipY

bool
Mirror vertically about the pivot.
default false

nineSlice

bool
Apply the region's nine-slice borders when resizing.
default false

lit

bool
Opt into normal-mapped local lights and geometric shadows.
default false

parallax

vec2
Parallax factor; one follows the world, zero follows the camera.
default [1,1]

Usage

Every edit is an undoable command: from the CLI as below, or the same JSON from an agent over MCP. See component.add and property.set.

Add it

ara do component.add -p entity=name:Crate -p component=Sprite --why "Add Sprite"

Set a field

ara do property.set -p entity=name:Crate -p path=Sprite.atlas -p value=null --why "Tune Sprite"

In a scene document

{
  "Sprite": {
    "atlas": null
  }
}

From C#

/// <summary>Face a sprite toward leftward movement.</summary>
public static void UseSprite(Entity entity, in Tick tick)
{
    ref var component = ref World.Get<Sprite>(entity);
    component.FlipX = true;
}

From C#

Scripts read and write it with Get<Sprite>(); see the Sprite struct.

Used by