dacha
    Preparing search index...

    Class Sprite

    Sprite component for rendering 2D textures.

    Handles the visual representation of an actor using a texture. It can be used to render a single texture or a texture slice from a sprite sheet.

    // Create a basic sprite
    const sprite = new Sprite({
    src: 'assets/player.png',
    width: 64,
    height: 64,
    slice: 0,
    flipX: false,
    flipY: false,
    sortingLayer: 'units',
    sortOffset: { x: 0, y: 0 },
    fit: 'stretch',
    color: '#ffffff',
    blending: 'normal',
    opacity: 1,
    disabled: false
    });

    // Add to actor
    actor.setComponent(sprite);

    // Modify properties
    sprite.opacity = 0.5; // Make semi-transparent
    sprite.color = '#ff0000'; // Apply a red tint

    Hierarchy (View Summary)

    Index
    actor?: Actor
    blending: BlendingMode

    Blending mode for rendering

    color: string

    Color tint applied to the sprite

    currentFrame?: number

    Current frame to render

    disabled: boolean

    Whether the sprite is disabled and should not render

    fit: FitType

    How the texture should fit within the sprite bounds

    flipX: boolean

    Whether to flip the sprite horizontally

    flipY: boolean

    Whether to flip the sprite vertically

    height: number

    Height of the sprite in pixels

    opacity: number

    Opacity from 0 (transparent) to 1 (opaque)

    renderData?: RenderData

    Internal rendering data

    slice: number

    Amount of frames in the sprite sheet

    sortingLayer: string

    Sorting layer name for rendering order

    sortOffset: Point

    Center point for sorting calculations

    src: string

    Path to the texture image file

    textureOffset: Point

    Texture sampling offset in pixels. Only applies to fit: 'repeat' With flipX/flipY the tile is mirrored, so a positive offset scrolls in the mirrored direction.

    width: number

    Width of the sprite in pixels

    componentName: string