loadSprite(name: string | null, src: LoadSpriteSrc | LoadSpriteSrc[], opt?: LoadSpriteOpt): Asset<SpriteData>
Load a sprite into asset manager, with name and resource url and optional config.
param
name- The asset name.
param
src- The resource url.
param
opt- The optional config.
// due to browser policies you'll need a static file server to load local files loadSprite("bean", "bean.png"); loadSprite("apple", "https://play.kaplayjs.com/sprites/apple.png"); // slice a spritesheet and add anims manually loadSprite("bean", "bean.png", { sliceX: 4, sliceY: 1, anims: { run: { from: 0, to: 3, }, jump: { from: 3, to: 3, }, }, });
returns
The asset data.
since
v2000.0