Jump to content

Can't load images


Recommended Posts

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>
    <script type="text/javascript" src="phaser.min.js"></script>
    <script type="text/javascript" src="game.js"></script>


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,


What wrong did I do? Please help

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...