I’m trying to do what seems to be basic image loading into my phaser3 game outside Phaser’s preload function, but nothing is working.
I tried:
- Lazy loading function in my utils.js:
dynImgLoader(textureKey,x,y,asset)
{
let loader = new Phaser.Loader.LoaderPlugin(this.scene);
loader.image(textureKey,asset);
loader.once(Phaser.Loader.Events.COMPLETE, ()=>
{
console.log('sprite ready for usage');
})
loader.start();
}
When called it still gives me the default phaser asset image (not loaded)
- I tried what this tutorial told me in index.js in create function:
this.load.image('arc_red', arc_red);
this.load.onLoadComplete.add(this);
this.load.start();
Still does not work.
Question:
How do I “dynamically” load assets for a multiplayer web socket game without using the preload function? And why is it that I am doing wrong?
I’m new to phaser and I desperately need to learn, thanks.