Name | Type | Description |
---|---|---|
baseUrl |
The base url for all resources loaded by this loader. |
|
concurrency |
The number of resources to load concurrently. |
Members
A premade instance of the loader that can be used to load resources.
Adds a resource (or multiple resources) to the loader queue.
This function can take a wide variety of different parameters. The only thing that is always required the url to load. All the following will work:
loader
// normal param syntax
.add('key', 'http://...', function () {})
.add('http://...', function () {})
.add('http://...')
// object syntax
.add({
name: 'key2',
url: 'http://...'
}, function () {})
.add({
url: 'http://...'
}, function () {})
.add({
name: 'key3',
url: 'http://...'
onComplete: function () {}
})
.add({
url: 'https://...',
onComplete: function () {},
crossOrigin: true
})
// you can also pass an array of objects or urls or both
.add([
{ name: 'key4', url: 'http://...', onComplete: function () {} },
{ url: 'http://...', onComplete: function () {} },
'http://...'
])
// and you can use both params and options
.add('key', 'http://...', { crossOrigin: true }, function () {})
.add('http://...', { crossOrigin: true }, function () {});
The base url for all resources loaded by this loader.
The number of resources to load concurrently.
- Default Value:
- 10
A querystring to append to every URL added to the loader.
This should be a valid query string without the question-mark (?
). The loader will
also not escape values for you. Make sure to escape your parameters with
encodeURIComponent
before assigning this property.
- Default Value:
- ''
Example
const loader = new Loader();
loader.defaultQueryString = 'user=me&password=secret';
// This will request 'image.png?user=me&password=secret'
loader.add('image.png').load();
loader.reset();
// This will request 'image.png?v=1&user=me&password=secret'
loader.add('iamge.png?v=1').load();
Loading state of the loader, true if it is currently loading resources.
- Default Value:
- false
onComplete PIXI.Signal
Dispatched when the queued resources all load.
onError PIXI.Signal
Dispatched once per errored resource.
onLoad PIXI.Signal
Dispatched once per loaded resource.
onProgress PIXI.Signal
Dispatched once per loaded or errored resource.
onStart PIXI.Signal
Dispatched when the loader begins to process the queue.
The progress percent of the loader going through the queue.
- Default Value:
- 0
resources object<string, PIXI.LoaderResource>
All the resources for this loader keyed by name.
Methods
PIXI.Loader.registerPlugin (plugin) typeof PIXI.Loader static
Adds a Loader plugin for the global shared loader and all new Loader instances created.
Name | Type | Description |
---|---|---|
plugin |
ILoaderPlugin |
The plugin to add |
Returns:
Type | Description |
---|---|
typeof PIXI.Loader | Reference to PIXI.Loader for chaining |
Destroy the loader, removes references.
Starts loading the queued resources.
Name | Type | Attributes | Description |
---|---|---|---|
cb |
Loader.OnCompleteSignal |
<optional> |
Optional callback that will be bound to the |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Sets up a middleware function that will run before the resource is loaded.
Name | Type | Description |
---|---|---|
fn |
ILoaderMiddleware |
The middleware function to register. |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Resets the queue of the loader to prepare for a new load.
Returns:
Type | Description |
---|---|
this | Returns itself. |
Sets up a middleware function that will run after the resource is loaded.
Name | Type | Description |
---|---|---|
fn |
ILoaderMiddleware |
The middleware function to register. |
Returns:
Type | Description |
---|---|
this | Returns itself. |