Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!