Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用相位器加载图像_Javascript_Html_Phaser Framework - Fatal编程技术网

Javascript 如何使用相位器加载图像

Javascript 如何使用相位器加载图像,javascript,html,phaser-framework,Javascript,Html,Phaser Framework,我正在尝试学习如何使用Phaser,按照在线说明如何加载图像;phaser提供的示例之一是负载图像示例 这是Phaser提供的代码 var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create }); function preload() { // You can fill the preloader with as many asse

我正在尝试学习如何使用Phaser,按照在线说明如何加载图像;phaser提供的示例之一是负载图像示例

这是Phaser提供的代码

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });

function preload() {

    //  You can fill the preloader with as many assets as your game requires

    //  Here we are loading an image. The first parameter is the unique
    //  string by which we'll identify the image later in our code.

    //  The second parameter is the URL of the image (relative)
    game.load.image('einstein', 'assets/pics/ra_einstein.png');

}

function create() {

    //  This creates a simple sprite that is using our loaded image and
    //  displays it on-screen
    game.add.sprite(0, 0, 'einstein');

}
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });

function preload() {

    //  You can fill the preloader with as many assets as your game requires

    //  Here we are loading an image. The first parameter is the unique
    //  string by which we'll identify the image later in our code.

    //  The second parameter is the URL of the image (relative)
    game.load.image('einstein', 'assets/pics/ra_einstein.png');

}

function create() {

    //  This creates a simple sprite that is using our loaded image and
    //  displays it on-screen
    game.add.sprite(0, 0, 'einstein');

}
html


实验
我试图在我的服务器上运行此代码(使用节点),但我看不到图像,有人能解释我做错了什么吗?

尝试在
内添加
标记

<html>
   <head>
       <meta charset="UTF-8">
       <title>Experiments</title>
       <script src="../phaser.js"></script>
       <script src="game.js"></script>
   </head>
   <body>
        <div id="phaser-example"></div>
   </body>
</html>
尝试在
标签中添加

<html>
   <head>
       <meta charset="UTF-8">
       <title>Experiments</title>
       <script src="../phaser.js"></script>
       <script src="game.js"></script>
   </head>
   <body>
        <div id="phaser-example"></div>
   </body>
</html>
尝试在
标签中添加

<html>
   <head>
       <meta charset="UTF-8">
       <title>Experiments</title>
       <script src="../phaser.js"></script>
       <script src="game.js"></script>
   </head>
   <body>
        <div id="phaser-example"></div>
   </body>
</html>
尝试在
标签中添加

<html>
   <head>
       <meta charset="UTF-8">
       <title>Experiments</title>
       <script src="../phaser.js"></script>
       <script src="game.js"></script>
   </head>
   <body>
        <div id="phaser-example"></div>
   </body>
</html>