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/phaser@3.0.0/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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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