Constructor
new Resources()
Creates a new instance of Resources.
- Source:
Members
(readonly) length :number
The number of resources currently available in the resource library.
Type:
- number
- Source:
Methods
add(name, data) → {undefined}
Add a new resource to the resource library.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Resource name (ID). |
data |
Object | Resource data. |
- Source:
Returns:
- Type
- undefined
clear() → {undefined}
Empty the resource library.
- Source:
Returns:
- Type
- undefined
get(name) → {rune.resource.Resource}
Retrieve a specific resource from the resource library. Each resource is
identified by a unique name (ID). If the desired resource cannot be found,
null is returned instead.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Resource name (ID). |
- Source:
Returns:
has(name) → {boolean}
Checks whether a resource exists in the library. Names are matched without
regard to case, using the same lookup as get().
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Resource name (ID). |
- Source:
Returns:
Whether the resource exists.
- Type
- boolean
remove(name) → {boolean}
Deletes a specific resource from the resource library. Deleted resources
are cleared from memory.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Resource name (ID). |
- Source:
Returns:
- Type
- boolean
request(options) → {undefined}
Request a set of files to load into the resource library during runtime.
The options.onError callback receives the failed resource name and an Error
for network or decoding failures. The failed batch is cleaned up first.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Request options. |
- Source:
Returns:
- Type
- undefined