Jump to content

Can't load images


Rubek
 Share

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>
<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,

 

What wrong did I do? Please help

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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