高分变量不适用于游戏
Highscore variable not working on game
我目前正在使用 Phaser 开发一款游戏,并尝试实现一个系统来保存当前得分的高分。由于某种原因它不起作用,我不知道为什么,它似乎没有根据当前分数更改 highscore 变量。
我已将简单游戏放在 Jsfiddle 上,代码如下:https://jsfiddle.net/zpy8wLqf/
这是我为 highscore 变量尝试的。
highscore=0;
var currentscore;
if(this.currentscore>highscore){
highscore =this.currentscore;
}
没有纹理,但这应该不是问题。
那是因为你的检查只在状态开始时运行,尝试将检查放在重置中
reset: function() {
if(this.currentscore>highscore){
highscore =this.currentscore;
}
// Start the 'main' state, which restarts the game
begin.state.start('adventure');
}
我目前正在使用 Phaser 开发一款游戏,并尝试实现一个系统来保存当前得分的高分。由于某种原因它不起作用,我不知道为什么,它似乎没有根据当前分数更改 highscore 变量。 我已将简单游戏放在 Jsfiddle 上,代码如下:https://jsfiddle.net/zpy8wLqf/ 这是我为 highscore 变量尝试的。
highscore=0;
var currentscore;
if(this.currentscore>highscore){
highscore =this.currentscore;
}
没有纹理,但这应该不是问题。
那是因为你的检查只在状态开始时运行,尝试将检查放在重置中
reset: function() {
if(this.currentscore>highscore){
highscore =this.currentscore;
}
// Start the 'main' state, which restarts the game
begin.state.start('adventure');
}