Loads media files to cache.
IMPORTANT: Must ONLY be used inside the function preload(), as it calls create() after all media is cached.
IMPORTANT: Must ONLY be used inside the function preload(), as it calls create() after all media is cached.
- Source:
- See:
-
- /js/globals.js for the list of media urls (var url)
Methods
(static) audio(urls)
Caches audio files using Fetch API.
Parameters:
Name | Type | Description |
---|---|---|
urls |
Array.<string> | audio urls for the current state |
- Source:
(static) finishedOneMediaElement(lastIndex, mediaType)
[Not directly used] Informs ONE media file was loaded to cache.
After ALL FILES of the SAME CATEGORY are cached, calls game.load.finishedOneMediaType()
After ALL FILES of the SAME CATEGORY are cached, calls game.load.finishedOneMediaType()
Parameters:
Name | Type | Description |
---|---|---|
lastIndex |
number | last index of the media array (to check if is finished) |
mediaType |
String | media category (to update the cached files from that category) |
- Source:
(static) finishedOneMediaType()
[Not directly used] Informs ALL MEDIA files from the SAME CATEGORY are cached.
After ALL CATEGORIES of media are cached, calls create() via game.state.
ATTENTION: Do not call create() directly.
After ALL CATEGORIES of media are cached, calls create() via game.state.
ATTENTION: Do not call create() directly.
- Source:
(static) getUncachedUrls(urls, media) → {Array.<string>}
[Not directly used] Removes the urls that are already in the cache.
Parameters:
Name | Type | Description |
---|---|---|
urls |
Array.<string> | array of urls |
media |
object | media category |
- Source:
Returns:
array of uncached urls
- Type
- Array.<string>
(static) image(urls)
Caches image files using HTMLImageElement.
Parameters:
Name | Type | Description |
---|---|---|
urls |
Array.<string> | image urls for the current state |
- Source:
(static) lang(url)
Loads language dictionary into the object game.lang using Fetch API.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | url for the selected language |
- Source:
(static) sprite(urls)
Caches spritesheets using HTMLImageElement.
Parameters:
Name | Type | Description |
---|---|---|
urls |
Array.<string> | spritesheet urls for the current state |
- Source: