Jump to content

Problems with loading image


Savo27
 Share

Recommended Posts

Hello to everyone 

I'm new with phaser 3, i'm having a lot of problems with loading images

So, my index.html is

<html>
<head>
<script src="phaser.js" ></script>
<script src="example.js" ></script>
<script src="game.js" ></script>
<script src="example2.js" ></script>
<script src="example3.js" ></script>
 
</head>
 
<body></body>
 
</html>

example.js

class example extends Phaser.Scene{
constructor() {
super({Key:"example"});
}
preload()
{
this.load.image('GFS','assets/GFS.jpg');
}
 
create()
{
this.image = this.add.image(800,640,'GFS');
}
 
}

game.js

var config = {
 
type: Phaser.AUTO,
width: 800,
eight : 640,
physics: {
default: 'arcade',
arcade : {
gravity : {y:200}
}
},
scene : [ example ]
};
 
var game = new Phaser.Game(config);

The error on chrome's console is 

phaser.js:39287 Failed to load file:///C:/Users/extro/Google%20Drive/Project/HTML/Index/assets/GFS.jpg: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

I can't find an answer to that on google or something else, I'm using xampp server.

 

I've also another problem to reach 

<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>

with chrome is displayed well on the URL, but in a scritp it give back that error

Failed to load resource: net::ERR_FILE_NOT_FOUND phaser.js:1
part1.html:18 Uncaught ReferenceError: Phaser is not defined
    at part1.html:18

 

Link to comment
Share on other sites

8 hours ago, mapacarta said:

Are you using a web server? The error you are getting is the error when you try to run phaser locally. The easiest way to use a web server locally is using Brackets's live preview I guess.

Also you can take a look at the getting started guide: http://phaser.io/tutorials/getting-started-phaser3

TY mapacarta for the reply

 

I'm using xammp as a web server

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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