Javascript 如何使用相位器加载图像
我正在尝试学习如何使用Phaser,按照在线说明如何加载图像;phaser提供的示例之一是负载图像示例 这是Phaser提供的代码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
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>