ecspresso
    Preparing search index...
    • Build an asset-manager-compatible loader for a PixiJS spritesheet atlas (TexturePacker JSON, etc.). Returns the fully-parsed Spritesheet object with .animations and .textures populated.

      The loader performs a runtime shape check on the resolved value — Assets.load<T> is purely nominal in PixiJS, so pointing this at a non-atlas URL would otherwise surface as a misleading 'animation not found' error deep in clipFromSheet/animationSetFromSheet. The shape check turns that into a load-time error with a clear message.

      To get literal animation-name inference, declare S as an interface ... extends SpritesheetData (a type alias re-widens via SpritesheetData.animations's Dict<string[]> string index signature).

      Type Parameters

      • S extends SpritesheetData = SpritesheetData

      Parameters

      • url: string

      Returns () => Promise<Spritesheet<S>>

      interface HeroData extends SpritesheetData {
      animations: { idle: string[]; walk: string[]; attack: string[] };
      }

      ecs.builder.withAssets(a => a
      .add('hero', spritesheetLoader<HeroData>('/hero.json'))
      );

      // Later:
      const sheet = ecs.assets.get('hero'); // Spritesheet<HeroData>
      const set = animationSetFromSheet('hero', sheet); // names inferred