karanJK Posted June 30, 2018 Share Posted June 30, 2018 i'm trying to load image on phaser 3 but on chrome consol says failed to load image also search for it, change code but can't solve it. here is my js code var config = { type: Phaser.AUTO, width: 800, height: 600, physics: { default: 'arcade', arcade: { gravity: {y: 500}, debug: false } }, scene: { preload: preload, create: create, update: update } }; var game = new Phaser.Game(config); function preload() { this.load.image('sky','src/assets/sky.png'); } function create() { this.add.image(400, 300, 'sky'); } function update() { } Link to comment Share on other sites More sharing options...
Vexen Crabtree Posted July 1, 2018 Share Posted July 1, 2018 What's the relative paths of the file that contains your code, and the asset you're loading? Link to comment Share on other sites More sharing options...
scope2229 Posted July 2, 2018 Share Posted July 2, 2018 If your file structure is like this GameFolder { Assets { sky.png } Src { index.js } then your load should be this this.load.image('sky','assets/sky.png'); //if you have another folder layout its like so this.load.image('sky', 'assets/levels/lvl1/sky.png'); All your javascript should be inside src and all you audio video images etc inside assets Link to comment Share on other sites More sharing options...
Recommended Posts