A little help updating a level field
Hi guys...
I have been thinking for a while already, but I cant figure out why this doesn´t work...
I have a script written to be "killing" enemies and each time an enemy gets killed, you get 10 points.
Now I tried to set it up to be levelling up each time you reach 200 points (at 200: lvl 2; at 400: lvl3; at 600: lvl4 and so on) but I was unable to do so.
Can you show me where I am making the mistake?
Here is what I have:
var level:int = 1;
var score:int = 0;
var lvlup:int = 200;
var updlvl:int = (lvlup * level); <<<< With this I am trying to use the var updlvl to have my level up each time I have added 200 points (when var level is 2, var
updlvl will be 200 * 2 = 400
UpdateFields();
function removeEnemy(){
updateScore(10);
UpdateFields();
if (enemy.parent) {enemy.parent.removeChild(enemy)};
recycleEnemy();
}
function updateScore(amount:int):void {
score += amount;
if(score < 0) score = 0;
if (updlvl = score) updateLevel(1);
}
function updateLevel(amount:int):void {
level += amount;
}
function UpdateFields():void {
score_txt.text = String(score);
level_txt.text = String(level);
lives_txt.text = String(lives);
}
Thanks a lot!!!