如何让 Phaser 应用我的 game.js 文件中的更改?
How do I make Phaser apply changes from my game.js file?
我尝试了 Phaser 教程。我创建了 index.html 加上一个名为 game.js 的 js 文件。
phaser.min.js 文件也已下载。
一切都在同一个文件夹中。
我正确地连接了所有东西并且输出工作得很好,但不知何故 Phaser 不再识别我的 game.js 中的变化。
这是我当前的 game.js 文件:
var config = {
type: Phaser.AUTO,
width: 640,
height: 360,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
function preload(){
this.load.image('boo', 'assets/pics/boo.png');
}
function create(){
this.add.image(0, 0, 'boo');
}
function update(){
}
我的 index.html 文件如下所示:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UFT-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1,
maximum-scale=1, minimum-scale=1, user-scalable=no" />
<title> My very 1st game </title>
<script type = "text/javascript" src = "phaser.min.js"></script>
<script type = "text/javascript" src = "game.js"></script>
<style type="text/css">
body {
margin: 0px;
}
</style>
</head>
<body>
</body>
</html>
包括 game.js 文件有效,如果我将其从头部部分删除,它就不再有效,因为它应该如此。
如果我要更改,例如将 width: 640
更改为 width: 200
,并且我刷新本地主机页面,它不会应用更改。
如果我检查页面,带有 width: 360
的旧文件仍在使用,即使它不再存在。
如果我将 game.js 文件中的代码放入 index.html 的正文中,它会应用更改。它不是通过包含 game.js 文件。
我使用 XAMPP 包括 Apache 网络服务器。
有什么提示可以尝试吗?任何东西都会受到赞赏。
问题出在缓存上。我用 ctrl+F5
刷新了游戏并应用了更改。
添加以下代码也可能有帮助:
<meta http-equiv="Cache-control" content="no-cache">
我尝试了 Phaser 教程。我创建了 index.html 加上一个名为 game.js 的 js 文件。 phaser.min.js 文件也已下载。 一切都在同一个文件夹中。
我正确地连接了所有东西并且输出工作得很好,但不知何故 Phaser 不再识别我的 game.js 中的变化。
这是我当前的 game.js 文件:
var config = {
type: Phaser.AUTO,
width: 640,
height: 360,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
function preload(){
this.load.image('boo', 'assets/pics/boo.png');
}
function create(){
this.add.image(0, 0, 'boo');
}
function update(){
}
我的 index.html 文件如下所示:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UFT-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1,
maximum-scale=1, minimum-scale=1, user-scalable=no" />
<title> My very 1st game </title>
<script type = "text/javascript" src = "phaser.min.js"></script>
<script type = "text/javascript" src = "game.js"></script>
<style type="text/css">
body {
margin: 0px;
}
</style>
</head>
<body>
</body>
</html>
包括 game.js 文件有效,如果我将其从头部部分删除,它就不再有效,因为它应该如此。
如果我要更改,例如将 width: 640
更改为 width: 200
,并且我刷新本地主机页面,它不会应用更改。
如果我检查页面,带有 width: 360
的旧文件仍在使用,即使它不再存在。
如果我将 game.js 文件中的代码放入 index.html 的正文中,它会应用更改。它不是通过包含 game.js 文件。
我使用 XAMPP 包括 Apache 网络服务器。
有什么提示可以尝试吗?任何东西都会受到赞赏。
问题出在缓存上。我用 ctrl+F5
刷新了游戏并应用了更改。
添加以下代码也可能有帮助:
<meta http-equiv="Cache-control" content="no-cache">