Im am trying to load images in phaser with node js and i always get the same error
:3000/assets/img/feet/idle/survivor-idle_0.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
if you know a way to get this to work please tell me. here is my code:
preload() {
// Used for preloading assets into your scene
//Idle feet image
this.load.image('idleFeetFrame', '/assets/img/feet/idle/survivor-idle_0.png');
}
(Updated from Comment) ... is my server code:
const express = require('express');
const app = express();
const server = app.listen(process.env.PORT || 3000);
app.use(express.static('./public'));
console.clear();
console.log('\x1b[36m%s\x1b[0m', 'Server started...\n');
const socket = require('socket.io');
const io = socket(server);
io.sockets.on('connection', handleConnection);
function handleConnection(socket) { console.log('Client: ' + socket.id + ' has connected.') }
Since there are not any special routes configured in express, I assume all your files are in the folder ./public
.
In that case the file survivor-idle_0.png
would have to be in the folder ./public/assets/img/feet/idle/survivor-idle_0.png
if you can't find it in that path, that is the problem (check for typos, or extra folder like src
).
As long as you are not using a bundler like webpack, parcel or so, just need to check your the public
folder and fix the paths.
If you are using a bundler, you will have to check the bundler configuration for errors.