Lav
12-28-2008, 01:10 PM
hello,
I'm trying to make a board game in flash and i want to use a sort of health system in my game, for example, if a player gets to a certain square, he will lose 1 hp but if he uses his hp-kit, everything will be repaired.
i first declared a globar var hp and made it 3, I then created 3 red squares next to eachother in a function
for(var i:int = 0; i<hp; i++)
{
this.graphics.beginFill(0xFF0000);
this.graphics.drawRect((kaderAvatar.x - 50)+i*15, 15, 15, 15);
this.graphics.endFill();
}
it works this far, but when i try to check what kind of square the player is on, and if it's the one where i need to reduce hp i simply use hp--; (the code to check what square its on works, i checked it with trace so no problem there)
now i'm a bit stuck where to go from here to make it actually work. I tried to make a different function that returns hp but i can't seem to make it work, anyone can help me?
And sorry if my english isn't that good
I'm trying to make a board game in flash and i want to use a sort of health system in my game, for example, if a player gets to a certain square, he will lose 1 hp but if he uses his hp-kit, everything will be repaired.
i first declared a globar var hp and made it 3, I then created 3 red squares next to eachother in a function
for(var i:int = 0; i<hp; i++)
{
this.graphics.beginFill(0xFF0000);
this.graphics.drawRect((kaderAvatar.x - 50)+i*15, 15, 15, 15);
this.graphics.endFill();
}
it works this far, but when i try to check what kind of square the player is on, and if it's the one where i need to reduce hp i simply use hp--; (the code to check what square its on works, i checked it with trace so no problem there)
now i'm a bit stuck where to go from here to make it actually work. I tried to make a different function that returns hp but i can't seem to make it work, anyone can help me?
And sorry if my english isn't that good