Jump to content

Image do not show on my script


Amdartoast
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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