Hello! I’m facing some issue with the loading process.
At the moment I’m able to load all of my assets on the runtime (outside the preload method) which is exactly what I desired at the time.
However, I would like to load other assets later on in the same scene. When I try to do it, it seems like the loader is not starting even if I’m calling it. The debug message ‘loading started’ is only trigger once.
My questions is : why is the loader only starting once? Thanks
export default class AssetLoader {
private scene: Phaser.Scene
constructor(scene: Phaser.Scene) {
this.scene = scene
// Load assets on start
this.scene.load.on('start', () => {
this.loadCommunAssets()
this.loadThemeAssets()
console.log("loading started")
})
// Load assets on events
EventDispatcher.getInstance().on('onTransition', this.onLoadSceneAssets)
}
// Callback to load new assets
private readonly onLoadSceneAssets = (targetKey: string): void => {
this.loadGameAssets(targetKey)
this.scene.load.start()
}
// Load game assets
private loadGameAssets(targetKey: string): void {
// [...]
}
}
Oh! Thanks for the precision. Basically, I would simply have to move the loadCommunAssets and loadThemeAsset methods outside the start callback in the constructor to queue those before starting the loader… I had some confusion there.
Hello, I changed the code a bit according to your saying and I still have the same issue.
Basically, when the game starts, only the game assets related to ‘shed’ are loading (which is OK). However, when the player interacts with some elements, I would like to load new assets but nothing seems to load. Why?