konfeti - v0.6.0
    Preparing search index...

    Function framesFromAtlas

    • Turn a Sprite Atlas JSON into Spritesheet Frames. Reads the frame list that TexturePacker, Aseprite, Free Texture Packer or Phaser export next to a packed sheet, in the order the atlas lists them, and returns the rectangles a spritesheet shape's frames takes. A name prefix picks one animation out of an atlas that holds several.

      Parameters

      • atlas: SpriteAtlas

        Atlas JSON ("JSON Hash" or "JSON Array" layout)

      • prefix: string = ""

        Only Frames Whose Name Starts with This (default: every frame)

      Returns FrameRect[]

      Frame Rectangles in Atlas Order

      TypeError for a malformed atlas, a rotated frame, or no frame matching the prefix

      import atlas from "./coins.json";

      Konfeti.fire({
      shapes: [{ type: "spritesheet", src: "/coins.png", frames: framesFromAtlas(atlas, "coin_spin") }],
      });

      Trimmed frames of different sizes are each stretched to the particle size; export animations without trimming (or with "keep size") so they do not wobble.