Amdartoast Posted September 3, 2018 Share Posted September 3, 2018 Hello, Im a verry newbie, first time with Javascript and so first time with Phaser. I just download .zip phaser files from github and installed it into my apache web server and I try a code wich work. But when I modify this code nothing work, please look : <!DOCTYPE html> <html> <head> <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script> </head> <body> <script> var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); function preload() { game.load.image('pic', 'image.jpg'); } function create() { // This simply creates an Image using the picture we loaded above and positions it at 100 x 100 // The difference between an Image and a Sprite is that you cannot animate or add a physics body to an Image var image = game.add.image(100, 100, 'pic'); } </script> </body> </html> Problem seems to be "image.jpg" location but comments on code says that image must be relative and my image.jpg is in the same folder as index.html so I dont understand.. Sorry for the very noob question Link to comment Share on other sites More sharing options...
rich Posted September 4, 2018 Share Posted September 4, 2018 The problem is that the code shown above is for Phaser 2 - and you're pulling in Phaser 3 from the CDN in your html. Either change the code, or the Phaser version to a Phaser CE release, and it'll work Amdartoast 1 Link to comment Share on other sites More sharing options...
Recommended Posts