- Home /
Question by
Eli-Davis · May 29, 2011 at 06:33 PM ·
functionrpgexperienceleveling
Leveling up in RPG
So I have a simple script, It works, but it's in an update function. I'm not exacly sure how to create my own function.. So could some one help show how to make it into its not called every frame and only called when needed.
static var electricityExp = 0;
var neededElectricity = 100;
static var electricity = 1;
function Update(){
if(electricityExp >= neededElectricity){
earth +=1;
//added effects...
neededElectricity += neededElectricity * 1.8;
}
}
Comment
Best Answer
Answer by jessee03 · May 29, 2011 at 06:49 PM
Just make a seperate function.
function Update()
{
if(electricityExp >= neededElectricity)
{
LevelUp();
}
}
function LevelUp ()
{
//level up code
}
Your answer is good but when posting code please highlight it and press the "10101" button. It will make it look neat and readable.
NOTE: I already did this for you.