Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda