melonJS
    Preparing search index...

    Function reload

    • Retry an asset that failed to load in a loader.preload (or a load(id)), given its src as reported by event.LOADER_ERROR.

      The retried asset counts towards the progress of the call it failed in, and once every asset of that call has loaded, that call completes: its own callback is called, if it was given one, and LOADER_COMPLETE is emitted. The promise that call returned has already rejected, and stays rejected. The asset then belongs to whoever asked for it: pinned if it was listed directly, held by its bundles if a bundle asked for it. Should it fail again, LOADER_ERROR is emitted again.

      Parameters

      • src: string

        the src of the asset to retry, exactly as in its descriptor (asset.src of the asset LOADER_ERROR passed)

      Returns void

      when no failed asset has that src

      import { event, loader } from "melonjs";

      event.on(event.LOADER_ERROR, (asset) => {
      // the game's own dialog, with a "retry" button
      showErrorDialog(`Could not load ${asset.name}`, () => {
      loader.reload(asset.src);
      });
      });