peteblank Posted December 8, 2018 Share Posted December 8, 2018 Hello I'm just starting out phaser 3. I followed the tutorial but I can't get the sprite to load. I used the following. function preload () { this.load.image('dog', 'dog.png'); } function create () { this.add.image(200,200,'dog'); } The dog.png image is located on the same folder. What am I doing wrong? Link to comment Share on other sites More sharing options...
peteblank Posted December 10, 2018 Author Share Posted December 10, 2018 never mind, sorry. Link to comment Share on other sites More sharing options...
Pillan Posted December 14, 2018 Share Posted December 14, 2018 I'm just starting out in phaser 3 as well, its pretty confusing haha. I believe you need to make a variable for the dog. The code should look like this: function preload() { this.load.image('dog', 'assets/dog.png'); } function create() { var dog = this.add.image('dog'); //You could also create "var dog" prior to this, and all you have to do here is: dog = this.add.image('dog'); } Link to comment Share on other sites More sharing options...
Telinc1 Posted December 14, 2018 Share Posted December 14, 2018 Making a variable wouldn't do anything by itself. It would be useful only if you need to reference the image later. It's likely that the problem here was not using a web server. Because of the security rules of browsers, you cannot load local files from within a web page, even one which is also a local file. You need to have a web server running locally so you can load files normally. snowbillr 1 Link to comment Share on other sites More sharing options...
Recommended Posts