Rubek Posted April 16, 2020 Share Posted April 16, 2020 I can’t load images for my phaser game? This is the problem I am trying to solve but I don’t know whatt now what mistake I have done. This is my index.html code, <!DOCTYPE html> <html> <head> <script type="text/javascript" src="phaser.min.js"></script> </head> <body> <script type="text/javascript" src="game.js"></script> </body> </html> And this is game.js code, function preload() { this.load.image('plant', 'plant.png'); } function create() { this.add.image(50,50, ‘plant’); } function update() { } const config = { type: Phaser.AUTO, height: 600, width: 600, background: 0x123456, scene: { preload: preload, create: create, update: update, } } const game = new Phaser.Game(config); The google console says, "Access to XMLHttpRequest at ‘file:///C:/wamp64/www/rungame/plant.png’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https." Also, there are other two messages by the console, Screenshot_21364×166 10.7 KB What wrong did I do? Please help Link to comment Share on other sites More sharing options...
EvilPixi Posted April 20, 2020 Share Posted April 20, 2020 (edited) Just a typing problem // use double quotes "plant.jpg" //or quotes 'plant.jpg' // but not ‘’ Edited April 20, 2020 by EvilPixi Link to comment Share on other sites More sharing options...
Recommended Posts