LogoPixi’VN
pixi-jsInterfaces

Interface: LoadOptions

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:20

Options for loading assets with the Loader

Example

await Assets.load(['file1.png', 'file2.png'], {
  onProgress: (progress) => console.log(`Progress: ${progress * 100}%`),
  onError: (error, url) => console.error(`Error loading ${url}: ${error.message}`),
  strategy: 'retry', // 'throw' | 'skip' | 'retry'
  retryCount: 5, // Number of retry attempts if strategy is 'retry'
  retryDelay: 500, // Delay in ms between retries
});

Standard

Properties

onError?

> optional onError?: (error, url) => void

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:49

Callback for handling errors during loading

Parameters

error

Error

The error that occurred

url

string | ResolvedAsset<any>

The URL of the asset that failed to load

Returns

void

Example

const options: LoadOptions = {
  onError: (error, url) => {
    console.error(`Failed to load ${url}: ${error.message}`);
  },
};
await Assets.load('missing-file.png', options);

onProgress?

> optional onProgress?: (progress) => void

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:34

Callback for progress updates during loading

Parameters

progress

number

A number between 0 and 1 indicating the load progress

Returns

void

Example

const options: LoadOptions = {
  onProgress: (progress) => {
    console.log(`Loading progress: ${progress * 100}%`);
  },
};
await Assets.load('image.png', options);

retryCount?

> optional retryCount?: number

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:77

Number of retry attempts if strategy is 'retry'

Default

3

Example

const options: LoadOptions = {
  strategy: 'retry',
  retryCount: 5, // Retry up to 5 times
};
await Assets.load('unstable-asset.png', options);

retryDelay?

> optional retryDelay?: number

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:90

Delay in milliseconds between retry attempts

Default

250

Example

const options: LoadOptions = {
  strategy: 'retry',
  retryDelay: 1000, // Wait 1 second between retries
};
await Assets.load('sometimes-fails.png', options);

strategy?

> optional strategy?: "throw" | "skip" | "retry"

Defined in: node_modules/pixi.js/lib/assets/loader/Loader.d.ts:64

Strategy to handle load failures

  • 'throw': Immediately throw an error and stop loading (default)
  • 'skip': Skip the failed asset and continue loading others
  • 'retry': Retry loading the asset a specified number of times

Default

'throw'

Example

const options: LoadOptions = {
  strategy: 'skip',
};
await Assets.load('sometimes-fails.png', options);