ourcade / phaser3-typescript-parcel-template

📦 For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools. 👾
MIT License
219 stars 106 forks source link

Cannot load image onto canvas #7

Open stevesmit opened 2 years ago

stevesmit commented 2 years ago

When I try to follow along with the tutorial and load a .png onto the canvas, it displays a neon green block with a line through it. I placed the image in public/tiles/ and then loaded it at that location too:

this.load.image('tiles', 'tiles/faune.png')

I don't get any errors on the dev tools console either? It's very strange. The out the box example (where it loads the phaser logo) works just fine, probably because it is not loading it from my filesystem. It might be worth mentioning that I had to use v2.0.0 of Parcel because I couldn't get the previous version to install.

alansegar commented 2 years ago

I had this same issue when using Parcel v2 / https://github.com/ourcade/phaser3-typescript-parcel-template/pull/8 I think it's due to the parcel-plugin-static-files-copy devDependency on this line https://github.com/ourcade/phaser3-typescript-parcel-template/blob/master/package.json#L24 not being compatible with Parcel v2.

If I change that line to "parcel-reporter-static-files-copy": "^1.3.0", and create a .parcelrc file containing the following:

{
  "extends": ["@parcel/config-default"],
  "reporters":  ["...", "parcel-reporter-static-files-copy"]
}

as described at https://github.com/elwin013/parcel-reporter-static-files-copy then it seems to serve from the local public folder successfully.

I also removed this line https://github.com/ourcade/phaser3-typescript-parcel-template/blob/master/package.json#L35 as there doesn't seem to be a watcher currently for v2.

biskwikman commented 2 years ago

@alansegar thanks for this! I was having the same issue and this works great.

biskwikman commented 2 years ago

I was able get it working while keeping the "parcel-reporter-static-files-copy" at 2.4.3 and keeping the "watcherGlob": "**" line. I just added .parcelrc file.