Tutorial: Assets Manager

Assets Manager

Assets Manager is an external module

It is used to load and hold game assets such as
tilmaps(.tmg files), images and audio.
To attach data use in the register() method:

register() {
    stage.iLoader.addAudio(key, url)
    stage.iLoader.addImage(key, url)
    stage.iLoader.addTileMap(key, url)
}

then call

app.preloadAllData()

after preloadAllData() promise will be resolved, data will be available with on init() and start() stages

start() {
    const audio = stage.iLoader.getAudio(key)
    const image = stage.iLoader.getImage(key)
    const tilemap = stage.iLoader.getTileMap(key)
    ...
}

*be careful with loading tilemaps and attached tilesets and images, everything should be in the same folder or subfolder.
Or you can manage tilesets loading separately, passing false as 3d parameter to addTileMap and then
adding addTileSet() calls:

    stage.iLoader.addTileMap(key, url, false);
    stage.iLoader.addTileSet(key, url, gui1);
    stage.iLoader.addTileSet(key, url, gui2);

*added audio files is better to register in the AudioInterface, How to add and use audio