Editing a question Because I have no longer privileges to Ask One.
So I have a Game Name Space XD: where
Game(main) class -> run()(gameloop)|-> render(gui) -> handler.render()(all Gameobjects render)
|-> tick() -> handler.tick()(all Gameobjects tick)
lets imagine a condition where player is in level 3 And on user input i want the game state the same as it was when player was in level two like points decreased, health at that particular moment etc..
I tried one solution
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.
}
Please Help!
You are missing the assignment of the new replaced value to text
as text = text.replace('public', 'oranges');
:
You can further use code[i].innerHTML = text;
to change the initial HTML with the replaced 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>