我怎样才能回到特定的游戏状态?
How can i go back to a specific game state?
正在编辑问题因为我不再有提问的权限。
所以我有一个游戏名称 Space XD:
其中
Game(main) class -> run()(gameloop)|-> render(gui) -> handler.render()(all Gameobjects render)
|-> tick() -> handler.tick()(all Gameobjects tick)
让我们想象一下玩家处于第 3 级的情况,在用户输入时我希望游戏状态与玩家处于第 2 级时相同,比如积分减少,
那个特定时刻的健康等..
我尝试了一种解决方案
if(level == 3){
this.game = previous_game; // i define previous_game = this.game; when level was 2. But nothing changed.
this.handler = handler; // same as up;
this.HUD = HUD;// heads of display but nothing was changed except i saw a black screen i thing because the background is black(background is black) please help i dont see any answers of this.
}
请帮忙!
您缺少将新替换值分配给 text
作为 text = text.replace('public', 'oranges');
:
您可以进一步使用 code[i].innerHTML = text;
将初始 HTML 替换为 HTML。
window.onload = (function(){
var code = document.getElementsByClassName('code');
for( i=0 ; i < code.length ; i++ ){
var text = code[i].innerHTML;
text = text.replace('public', 'oranges');
code[i].innerHTML = text;
console.log(text);
}
})
<p class = "code"> public stasdfadtic void main sdfdsa </p>
<p class = "code"> public static void main </p>
正在编辑问题因为我不再有提问的权限。
所以我有一个游戏名称 Space XD: 其中
Game(main) class -> run()(gameloop)|-> render(gui) -> handler.render()(all Gameobjects render)
|-> tick() -> handler.tick()(all Gameobjects tick)
让我们想象一下玩家处于第 3 级的情况,在用户输入时我希望游戏状态与玩家处于第 2 级时相同,比如积分减少, 那个特定时刻的健康等..
我尝试了一种解决方案
if(level == 3){
this.game = previous_game; // i define previous_game = this.game; when level was 2. But nothing changed.
this.handler = handler; // same as up;
this.HUD = HUD;// heads of display but nothing was changed except i saw a black screen i thing because the background is black(background is black) please help i dont see any answers of this.
}
请帮忙!
您缺少将新替换值分配给 text
作为 text = text.replace('public', 'oranges');
:
您可以进一步使用 code[i].innerHTML = text;
将初始 HTML 替换为 HTML。
window.onload = (function(){
var code = document.getElementsByClassName('code');
for( i=0 ; i < code.length ; i++ ){
var text = code[i].innerHTML;
text = text.replace('public', 'oranges');
code[i].innerHTML = text;
console.log(text);
}
})
<p class = "code"> public stasdfadtic void main sdfdsa </p>
<p class = "code"> public static void main </p>