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

406
Vistas
Phaser, Image Replaced By Green Square, No Errors, JS

I followed many Phaser tutorials online with precision, and made sure the path to the image is adequate, yet I find myself stuck with a green square with a dash across it in place for my image green square.

I have suspicions that perhaps it's the way I have my testing server set up, I am using parcel for this. I've tried many implementations of loading images using Phaser's preLoad() function, but even the simplest one this.load.image('testing','../../assets/user/body/moveRightAtlas.png'); (in preLoad) and var testing=this.add.sprite(400,400,'testing'); (in create) still prints the square. For the path, I've tried absolute path and still does not work. Here is how my directories are set up. directories . My question is, what am I doing incorrect? I'm an absolute noob in Phaser, so any help is deeply appreciated, thanks.

(EDIT: for the directories screenshot I accidently said moveRight0, I meant moveRightAtlas.png)

After reading more, it seems that the image exists but the web server I am using to test the game can't seem to load it. So the issue is likely on the webserver. I am using parcel.

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

0

The path should be relative to the HTML file, so in your case:

this.load.image('testing','assets/user/body/moveRightAtlas.png');
about 4 years ago · Juan Pablo Isaza Denunciar

0

You should probably move the assets directory inside your src and then go from there.

Here's how this samme's repository for a working parcel setup is doing the imports :

[...]
    import images from './assets/*.png';
[...]
    this.load.image('space', images.space);
[...]

In your case it'd probably be something like:

[...]
     import moveRightAtlas from './assets/user/body/moveRightAtlas.png'; 
[...]
     this.load.image('testing', moveRightAtlas);
[...]

Check also its README for a plugin to copy the assets.

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