Class: PreloadManager

DKTools.PreloadManager

Preload manager class

new DKTools.PreloadManager ()

Since:
  • 3.0.0

Members

DKTools.PreloadManager._cache Object privatestaticreadonly

DKTools.PreloadManager._files Object privatestaticreadonly

Since:
  • 9.0.0

DKTools.PreloadManager._queue Array.<Object> privatestaticreadonly

_cache Object privatereadonly

_queue Array.<Object> privatereadonly

Methods

DKTools.PreloadManager._finish () privatestatic

Finishes the preloading
Version:
  • 9.0.0

DKTools.PreloadManager._generateAudioKey (path)String privatestatic

Generates an audio key
Name Type Description
path String Path
Since:
  • 5.0.0
Returns:
Type Description
String Generated key

DKTools.PreloadManager._generateImageKey (path, hue)String privatestatic

Generates an image key
Name Type Default Description
path String Path
hue Number 0 optional Hue
Since:
  • 5.0.0
Returns:
Type Description
String Generated key

DKTools.PreloadManager._log (message) privatestatic

Logs the message in the console
Name Type Description
message String Message
Version:
  • 9.0.0

DKTools.PreloadManager._onFileLoad (data) privatestatic

Processes the loading of the data
Name Type Description
data WebAudio | Bitmap Data
Version:
  • 10.0.4
Since:
  • 5.0.0

DKTools.PreloadManager._preload (type, object) privatestatic

Adds the object to preload queue
Name Type Description
type String Type (audio or image)
object Object Object with parameters
Name Type Description
path String Path to file or directory
hue Number optional Hue (only for images)
caching Boolean optional Caching
Version:
  • 10.0.5
Since:
  • 5.0.0

DKTools.PreloadManager._processAudioFile (file, object) privatestatic

Name Type Description
file DKTools.IO.File
object Object
Version:
  • 10.0.4
Since:
  • 9.0.0

DKTools.PreloadManager._processImageFile (file, object) privatestatic

Name Type Description
file DKTools.IO.File
object Object
Since:
  • 9.0.0

DKTools.PreloadManager._processLoadAudioFiles ()Array.<Promise> privatestatic

Processes audio loading
Version:
  • 9.0.0
Since:
  • 5.0.0
Returns:
Type Description
Array.<Promise> Loaded audio files

DKTools.PreloadManager._processLoadImageFiles ()Array.<Promise> privatestatic

Processes image loading
Version:
  • 9.0.0
Since:
  • 5.0.0
Returns:
Type Description
Array.<Promise> Loaded image files

DKTools.PreloadManager.canPreloadAudioFiles ()Boolean static

Returns true if can preload audio files
Since:
  • 10.0.5
Returns:
Type Description
Boolean Can preload audio files

DKTools.PreloadManager.canPreloadImageFiles ()Boolean static

Returns true if Can preload image files
Since:
  • 10.0.5
Returns:
Type Description
Boolean Can preload image files

DKTools.PreloadManager.clearCache () static

Clears the cache
Version:
  • 5.0.0

DKTools.PreloadManager.clearQueue () static

Clears the preload queue
Version:
  • 9.0.0

DKTools.PreloadManager.getCachedAudioByKey (key)WebAudio | undefined static

Returns a cached audio by key
Name Type Description
key String Key of the cached audio
Since:
  • 5.0.0
Returns:
Type Description
WebAudio | undefined Cached audio by key

DKTools.PreloadManager.getCachedAudioByPath (path)WebAudio | undefined static

Returns a cached audio by path
Name Type Description
path String Path of the cached audio
Since:
  • 5.0.0
Returns:
Type Description
WebAudio | undefined Cached audio by path

DKTools.PreloadManager.getCachedImageByKey (key)Bitmap | undefined static

Returns a cached image by key
Name Type Description
key String Key of the cached image
Since:
  • 5.0.0
Returns:
Type Description
Bitmap | undefined Cached bitmap or null

DKTools.PreloadManager.getCachedImageByPath (path)Bitmap | undefined static

Returns a cached image by path
Name Type Description
path String Path of the cached image
Since:
  • 5.0.0
Returns:
Type Description
Bitmap | undefined Cached image or null

DKTools.PreloadManager.getTotal ()Number static

Returns the total amount of resources to preload
Since:
  • 8.3.0
Returns:
Type Description
Number Total amount of resources to preload

DKTools.PreloadManager.initialize () static

Initializes preloading
Version:
  • 9.0.0

DKTools.PreloadManager.isAudioCachedByKey (key)Boolean static

Returns true if the audio by key is cached
Name Type Description
key String Key of the cached audio
Since:
  • 5.0.0
Returns:
Type Description
Boolean Audio by key is cached

DKTools.PreloadManager.isAudioCachedByPath (path)Boolean static

Returns true if the audio by path is cached
Name Type Description
path String Path of the cached audio
Since:
  • 5.0.0
Returns:
Type Description
Boolean Audio by path is cached

DKTools.PreloadManager.isFinished ()Boolean static

Returns true if the preloading is finished
Since:
  • 5.0.0
Returns:
Type Description
Boolean Preloading is finished

DKTools.PreloadManager.isImageCachedByKey (key)Boolean static

Returns true if the image by key is cached
Name Type Description
key String Key of the cached image
Since:
  • 5.0.0
Returns:
Type Description
Boolean Image by key is cached

DKTools.PreloadManager.isImageCachedByPath (path, hue)Boolean static

Returns true if the image by path is cached
Name Type Default Description
path String Path of the cached image
hue Number 0 optional Hue
Since:
  • 5.0.0
Returns:
Type Description
Boolean Image by path is cached

DKTools.PreloadManager.isReady ()Boolean static

Returns true if the preload manager is ready
Since:
  • 6.1.0
Returns:
Type Description
Boolean Preload manager is ready

DKTools.PreloadManager.isStarted ()Boolean static

Returns true if the preloading is started
Since:
  • 9.0.0
Returns:
Type Description
Boolean Preloading is started

DKTools.PreloadManager.onFileLoad (callback) static

Adds a callback function to handle file load All callback functions will be cleared after the preload is finished Callback function takes 1 argument - object with following properties: file (WebAudio or Bitmap), loaded, total
Name Type Description
callback function Callback
Since:
  • 8.3.0
Example
DKTools.PreloadManager.onFileLoad(() => {
    Graphics.updateLoading();
});

DKTools.PreloadManager.onFinish (callback) static

Adds a callback function to handle finish of preloading All callback functions will be cleared after the preload is finished Callback function takes 1 argument - object with following properties: loaded, skipped, preloadingTime (seconds), total
Name Type Description
callback function Callback
Since:
  • 8.3.0
Example
DKTools.PreloadManager.onFinish(() => {
    Graphics.endLoading();
});

DKTools.PreloadManager.preloadAudio (object) static

Adds the audio to preload queue
Name Type Description
object Object Object with parameters
Name Type Description
path String Path to file or directory (only for local mode)
caching Boolean optional Caching
Version:
  • 10.0.5
Since:
  • 5.0.0
Examples
// folder preloading
const path = 'audio/se/';

DKTools.PreloadManager.preloadAudio({
    path: path,
    caching: false
});

DKTools.PreloadManager.start();
// file preloading
// auto converts extension for mobile devices
const path = 'audio/se/Cancel1.ogg';

DKTools.PreloadManager.preloadAudio({
    path: path,
    caching: false
});

DKTools.PreloadManager.start();

DKTools.PreloadManager.preloadImage (object) static

Adds the image to preload queue
Name Type Description
object Object Object with parameters
Name Type Description
path String Path to file or directory (only for local mode)
hue Number optional Hue
caching Boolean optional Caching
Version:
  • 10.0.5
Since:
  • 5.0.0
Examples
// folder preloading
const path = 'img/system/';

DKTools.PreloadManager.preloadImage({
    path: path,
    hue: 0,
    caching: false
});

DKTools.PreloadManager.start();
// file preloading
const path = 'img/system/Window.png';

DKTools.PreloadManager.preloadImage({
    path: path,
    hue: 0,
    caching: false
});

DKTools.PreloadManager.start();

DKTools.PreloadManager.releaseAudioByKey (key) static

Releases the audio by key from a cache
Name Type Description
key String Key of the cached audio
Since:
  • 5.0.0

DKTools.PreloadManager.releaseAudioByPath (path) static

Releases the audio by path from a cache
Name Type Description
path String Path of the cached audio
Since:
  • 5.0.0

DKTools.PreloadManager.releaseImageByKey (key) static

Releases the image by key from a cache
Name Type Description
key String Key of the cached image
Since:
  • 5.0.0

DKTools.PreloadManager.releaseImageByPath (path, hue) static

Releases the image by path from a cache
Name Type Description
path String Path of the cached image
hue Number optional Hue
Since:
  • 5.0.0

DKTools.PreloadManager.setDebugging (enabled) static

Sets the output of debugging information to the console Each finish resets debugging
Name Type Description
enabled Boolean Enable output
Since:
  • 9.0.0

DKTools.PreloadManager.start ()Promise static

Starts the preloading Returns the promise
Version:
  • 9.0.0
Returns:
Type Description
Promise