Jump to content

Image do not show on my script


Recommended Posts


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>
    <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></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');




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


  • Recently Browsing   0 members

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