Assets

Functions

loadImage

(url: string, options?: SurfaceCreateOptions) ⇨ Promise<Surface>

Loads an image by url and create instance of a the surface object


Example:

async function loadAssets () {
  const image = await loadImage('https://example.com/image.jpg', { useAlpha: false })
  ...
}

loadBlob

(blob: Blob, options?: SurfaceCreateOptions) ⇨ Promise<Surface>

Loads an image from BLOB and create instance of the surface object


Example:

async function onFileUpload (ev: Event) {
  const files = ev.target.files
  if (!files || !files[0]) return
  
  const image = await loadBlob(files[0])
  ...
}
...
<input type="file" onchange="onFileUpload">
...

loadTileMap

(tileWidth: number, titleHight: number, url: string, options?: TileMapInitOptions) ⇨ Promise<TileMap>

Loads an tilemap by url and create instance of the TileMap object

createTileMap

(tileWidth: number, titleHight: number, urls: string[], rows: number, cols: number, options?: TileMapInitOptions) ⇨ Promise<TileMap>

Creates an tilemap from image files and create instance of the TileMap object