fac*_*ial 1 javascript html5 phaser-framework
在过去的几天里,我一直无法让移相器工作:只是试着测试一个hello world程序.我完全遵循了phaser网站上的指示,但它仍然不适合我.
我正在使用node.js.
这是index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<style>
#game_div {
width: 500px;
margin: auto;
margin-top: 50px;
}
</style>
<script type="text/javascript" src="phaser.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div id="game_div"> </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是main.js:
/*jslint node: true */
"use strict";
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');
var main_state = {
preload: function () {
game.load.image('hello', 'assets/hello.png');
},
create: function () {
this.hello_sprite = game.add.sprite(200, 245, 'hello');
},
update: function () {
this.hello_sprite.angle += 1;
}
}
game.state.add('main', main_state);
game.state.start('main');
Run Code Online (Sandbox Code Playgroud)
它给我的错误是:
"Phaser"在定义之前就被使用了.
var game = new Phaser.Game(400,490,Phaser.AUTO,'game_div');
我真的试过寻找解决方案,但我找不到任何错误.我是JavaScript和phaser的新手.
上面的SecurityError指向问题的根源:您正在浏览器中直接打开文件,在该浏览器下您无权访问此类本地文件.它需要通过Web服务器提供.如果您需要任何帮助,我们将在网站的"入门指南"中介绍它.
| 归档时间: |
|
| 查看次数: |
2541 次 |
| 最近记录: |