Loader
The Loader module is responsible for loading additional resources into the engine.
Usage
To use this module, add the following require at the top of your script:
Reference
getItemCountToLoad
Return how many items are currently beeing loaded
Returns
number: count
loadImage
Loads an image from an item by its relative path
Parameters
path(string): relative path to the image file inside the project i.e. ("/resources/textures/tex1")options: object with the following keys:flipY(boolean): if set to true, image will be flipped. for canvas rendering this should be set to false. default = truewaitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the texture is fully loaded. default = false
Returns
Promise: a promise that will deliver a Texture object
loadMaterial
Loads a material by path and will emit an loadMaterialResult event when the material is ready or loadMaterialError event on error
Parameters
path(string): relative path to the material item inside the project i.e. ("/resources/materials/mat1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the material is fully loaded. default = false
Returns
Promise: a promise that will deliver a Material object
loadMesh
Loads a mesh from an item by its relative path.
Parameters
path(string): relative path to the mesh item inside the project i.e. ("/resources/meshes/mesh1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the mesh is fully loaded. default = false
Returns
Promise: a promise that will deliver a Mesh object
loadPrefab
Loads a prefab from an item by its relative path.
Parameters
path(string): relative path to the prefab item inside the project i.e. ("/resources/meshes/prefab1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the prefab is fully loaded. default = false
Returns
Promise: a promise that will deliver a Prefab object
loadGridMap
Loads a gridmap from an item by its relative path.
Parameters
path(string): relative path to the gridmap item inside the project i.e. ("/resources/gridmaps/gridmap1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the gridmap is fully loaded. default = false
Returns
Promise: a promise that will deliver a GridMap object
loadFont
Loads a font from an item by its relative path. Once this is loaded, it can be instantly used in canvas by its name for example Canvas.setFont("20px font1")
Parameters
path(string): relative path to the font item inside the project i.e. ("/resources/fonts/font1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the font is fully loaded. default = false
Returns
Promise: a promise that will deliver a Font object
loadStructuredData
Loads a structured data item by its relative path.
Parameters
path(string): relative path to the structured data item inside the project i.e. ("/resources/data/level1")options: object with the following keys:waitUntilFinished(boolean): if set to true, the promise will only fulfil as soon as the data is fully loaded. default = false
Returns
Promise: a promise that will deliver a Structured Data object