Namespace: resource
Namespaces
Classes
Interfaces
Type Aliases
ResourceDefinition
Ƭ ResourceDefinition: Resource
| string
Resource definition for loading a resource.
Functions
addBundleMap
▸ addBundleMap(data
): void
Add an externally loaded BundleMap
to the resource system.
Parameters
Name | Type | Description |
---|---|---|
data |
BundleMap |
Bundle map data |
Returns
void
destroy
▸ destroy(path
): void
Destroy a LoaderResource
. Does nothing if the resource is not found.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
Path of the resource |
Returns
void
get
▸ get(path
): LoaderResource
| undefined
Get a previously loaded LoaderResource
. Returns undefined
if the resource is not found.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
Path of the resource |
Returns
LoaderResource
| undefined
▸ get<T
>(type
, path
): T
| undefined
Get a previously loaded LoaderResource
. Returns undefined
if the resource is not found or is
not of the requested type.
Type parameters
Name | Type |
---|---|
T |
extends LoaderResource |
Parameters
Name | Type | Description |
---|---|---|
type |
Type <T > |
Type of the resource |
path |
string |
Path of the resource |
Returns
T
| undefined
getBundleMap
▸ getBundleMap(): BundleMap
Get the bundle mapping information.
Returns
load
▸ load(resource
, options?
): Promise
<LoaderResource
>
Load a single resource. The resource loader has a built-in retry system that can be configured
via the options
parameter. Retry count defaults to 0
whereas the retry delay defaults to
5000
milliseconds (5 seconds).
The resource can be provided as a simple string
path or a Resource
interface with path
and
options
properties.
Parameters
Name | Type | Description |
---|---|---|
resource |
ResourceDefinition |
Resource to load |
options? |
LoadOptions |
Load options |
Returns
Promise
<LoaderResource
>
▸ load(resources
, options?
): Promise
<LoaderResource
[]>
Load a collection of resources. The resource loader has a built-in retry system that can be
configured via the options
parameter. Retry count defaults to 0
whereas the retry delay
defaults to 5000
milliseconds (5 seconds).
The resources in the list can include simple string
paths or a Resource
interface with
path
and options
properties.
Parameters
Name | Type | Description |
---|---|---|
resources |
ResourceDefinition [] |
List of resources to load |
options? |
LoadOptions |
Load options |
Returns
Promise
<LoaderResource
[]>
paths
▸ paths(): Generator
<string
>
Returns an iterator for resource paths.
Returns
Generator
<string
>
registerResourcePathHandlers
▸ registerResourcePathHandlers(...handlers
): void
Register a handler for resolving path names for special naming conventions. Example: PixiSound supports audio sprite {ogg,mp3,…} style dependencies Handlers registered later are checked first.
Parameters
Name | Type | Description |
---|---|---|
...handlers |
ResourcePathHandler [] |
Handler(s) to register |
Returns
void
registerXhrExtensions
▸ registerXhrExtensions(extensions
): void
Register one or more extensions for loading xhr
resources. The extension mapping is used to
determine the xhr
request response type. The response type should be a type that the loader
for the file type can handle.
If the file extension mapping for a file is not found the default response used is blob
.
Parameters
Name | Type | Description |
---|---|---|
extensions |
Record <string , "text" | "arraybuffer" | "blob" | "json" > |
Extension(s) to register |
Returns
void
registerXhrLoaders
▸ registerXhrLoaders(...loaders
): void
Register one or more loaders for creating LoaderResource
instances from
xhr.LoadResultSuccess
response data.
Parameters
Name | Type | Description |
---|---|---|
...loaders |
XhrLoader <LoaderResource >[] |
Loader(s) to register |
Returns
void
require
▸ require(path
): LoaderResource
Get a previously loaded LoaderResource
. Throws an error if the resource is not found.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
Path of the resource |
Returns
▸ require<T
>(type
, path
): T
Get a previously loaded LoaderResource
. Throws an error if the resource is not found or is not
of the requested type.
Type parameters
Name | Type |
---|---|
T |
extends LoaderResource |
Parameters
Name | Type | Description |
---|---|---|
type |
Type <T > |
Type of the resource |
path |
string |
Path of the resource |
Returns
T
set
▸ set(path
, resource
): LoaderResource
Set a LoaderResource
to a path from an external source.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
Path of the resource |
resource |
LoaderResource |
Loader resource to set |
Returns
setAlias
▸ setAlias(from
, to
): void
Set a resource alias to map resources during loading. This can be used for example to change resources based on language.
Parameters
Name | Type | Description |
---|---|---|
from |
string |
Original resource to map |
to |
string |
New resource to point to |
Returns
void