-
movieclips and score
I am working on a game where you must shoot another player that tries to shoot you:) But that is not that important. Here's the problem...
I have a health bar that works and i would like to make it keep score. I have tried several different ways but to no avail. This health bar has several keyframes inside of it for the decreasing health and i have tried to make it add to the players score when the health bar hits 0 and show it in the next frame/level. I think the reason it is not working has something to do with when the game goes to another frame, although i am not sure. I am completely confused right now so any help would be greatly appreciated:cap:
-
Does anyone have any idea to do this!:confused: Please help
-
You could perhaps explain it more. Do you have text field inside health bar movie clip and you want to show some numbers there or do you want to add points to global score every time health is reduced?
-
I don't really care how it's done as long I can keep a score that will transfer from frame to frame without resetting. I don't have a text field inside of the healthbar, i think a global score would be the best (just a guess:shhh: ).
By the way, What is global? i have a hunch but i am not sure. Is it something that lasts throughout all the frames?
Sorry. i am kind of new:yarr:
-
^Yep.Global == everywhere accessible variable.
If you want to keep the score through all frames, you could do somthing like this: (All written in the main timeline)
PHP Code:
_root.scoreTXT = 0; //Sets the score variable to 0.
Now, if you have written some code in the hero's movie clip, then you can do somthing like this:
PHP Code:
onClipEvent(enterFrame) {
if (_root.enemy.hitTest(this._X, this._y, true) == true) {
_root.score += 5; //Adds 5 to the score variable
}
}
That is basically how you can access the variable.
Hope that helps, and if unclear, just post it.