I'm doing a round based game. So after you've killed so many enemies it'll pop up, "Round 1", after some more, "Round 2" and so on. The amount of enemies doesn't change it's just the round that increases after you've killed say 20 enemies.
I have a current variable at the top of my game.js file
var currRound = 1;
var EnemiesKilled = 0;
Every time I kill an enemy I increment up the variable then in one of the collision handlers I do if EnemiesKilled == 20 then show some text
newLevel.setText("Woo!! Round " + currRound + "!");
and restart the round via
setTimeout(function() {
game.state.start(game.state.current);
}, 1000);
The thing is, it whipes the variable of EnemiesKilled. How can I keep that variable so I always know how many enemies the player has killed?