The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsI really hate having to post questions, but I have searched google and I did not find anything... So, I have the health bar completely set up. I just want to know how to make it regenerate over time. I do not know if flash has a timer function, so I was using variables. But the problem was, everything worked fine. But when I leveled up, the variable continued counting down, and then when it got to 0, it added more health... I completely deleted the whole timer variable because of this.
I feel that there has to be an easier way, I just don't know how... By the way, I am using AS2. Any help would be greatly appreciated.
When I used to use AS2 I would do those variables timers like what you're talking about. They work pretty well you just need to add a boolean check if your game ends or if the player dies. So you would do something like.
var healthTicks:int = 0; // these are ticked every frame
var healthMax:int = 30; //how long until health is increased
var health:int = 100; //player health
var isLeveledUp:Boolean = false; //set this to true when you want it to stop going up
//put this stuff in an enterframe
healthTicks++;
if (isLeveledUp==false&&healthTicks>=health Max&&health<=100) {
health++;
healthTicks = 0;
}
Flash does have a timer class, but this won't really solve the problem you're having. It's been a long time since I did AS2 so this is really just psuedo code. Hope it helps.