loadSpriteAtlas(src: LoadSpriteSrc, data: SpriteAtlasData): Asset<Record>
Load sprites from a sprite atlas.
param
src- The image resource url.
param
data- The sprite atlas data.
// See #SpriteAtlasData type for format spec loadSpriteAtlas("sprites/dungeon.png", { "hero": { x: 128, y: 68, width: 144, height: 28, sliceX: 9, anims: { idle: { from: 0, to: 3 }, run: { from: 4, to: 7 }, hit: 8, }, }, }); const player = add([ sprite("hero"), ]); player.play("run");
returns
The asset data.
since
v2000.0