Class: Assets

core~Assets()

Manages loading and caching of assets (images and audio)

Constructor

new Assets()

Source:
Fires:

Extends

Members

audioBuffers :object

A dictionary containing all audio buffers.
Type:
  • object
Source:

audioCtx :AudioContext

Native AudioContext for encoding loaded audio to audiobuffers. If this is undefined, HTML5 Audio is being used as a fallback. .
Type:
  • AudioContext
Source:

blobs :object

A dictionary containing all audio blobs.
Type:
  • object
Source:

cache :object

A dictionary containing all loaded assets.
Type:
  • object
Source:

engine :module:core~Engine

A reference to the main engine.
Type:
Source:

listeners :object

A dictionary of the event callbacks attached to this object.
Type:
  • object
Overrides:
Source:

progress :number

Number between 0 and 1, indicating the progrees of the queue. 1 is complete. .
Type:
  • number
Source:

queueLength :number

Current number if items waiting to come back from the network.
Type:
  • number
Source:

queueMax :number

How many items there where when the queue started. .
Type:
  • number
Source:

Methods

emit(type, eopt)

Emits the event of a certain type and executes all callbacks.
Parameters:
Name Type Attributes Description
type string The name of the event it emits.
e object <optional>
An optional object that will be passed to the callbacks first argument.
Overrides:
Source:

getAudioBufferByName(name) → {AudioBuffer|undefined}

Get audiobuffer cache item by name.
Parameters:
Name Type Description
name string The name you gave the asset.
Source:
Returns:
Type
AudioBuffer | undefined

getBlobByName(name) → {DOMString|undefined}

Get blob cache item by name.
Parameters:
Name Type Description
name string The name you gave the asset.
Source:
Returns:
Type
DOMString | undefined

getByName(name) → {Image|Audio|undefined}

Get cache item by name.
Parameters:
Name Type Description
name string The name you gave the asset.
Source:
Returns:
Type
Image | Audio | undefined

load(assets)

Starts the loading of assets.
Parameters:
Name Type Description
assets Array.<object> An array of predefined assets.
Properties
Name Type Attributes Description
name string A unique name to store it in the cache. You can also use the name to reference this asset in your code.
type string 'image' or 'audio'
src string The path where the file can be loaded over the network. Can also be a data-uri.
chunks Array.<object> <optional>
An array for the parts of an audio sprite.
Properties
Name Type Description
start number Start time of the sound bite in seconds.
end number End time of the sound bite in seconds.
Source:

off(typeopt, callbackopt)

Removes listeners from this object.
Parameters:
Name Type Attributes Description
type string <optional>
The name of the event to remove callback(s) for. If left empty, it will remove every single callback from this object.
callback function <optional>
The callback to remove. If left empty, it will remove all callbacks for the given type or when the type is empty every single callback on this object.
Overrides:
Source:

on(type, callback)

Continually listen on this object for an event.
Parameters:
Name Type Description
type string The name of the event.
callback function The function to execute each time the event is emitted.
Overrides:
Source:

once(type, callback)

Listen on this object for an event, but execute the callback only once.
Parameters:
Name Type Description
type string The name of the event.
callback function The function to execute once.
Overrides:
Source:

Events

queuedone

Fired when all assets in the queue are loaded.
Source: