Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Javascript Phaser3 Assets Not Loading In Create Function

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you use this code in the create function (or other non preload functions) it should work:.

this.load.image(key, url);   // add task
this.load.once('complete', callback, scope);  // add callback of 'complete' event
this.load.start();                     // start loading

I got it from this documentation, and it works in my demo code.

Here a working example on Phaser.io

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda