Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do i make a HP bar for my player
- rennamleart
-
9 posts
how do i make a HP bar for my player
im making an rpg game and need an hp bar. how do i do this?
- RaMo-9
-
7 posts
how do i make a HP bar for my player
I haven't tried this in a project yet, but try it anyways:
Different code now:
Hope this helps!
Different code now:
Hope this helps!
Last edited by RaMo-9 (June 1, 2022 10:21:48)
- randomguy3513
-
1000+ posts
how do i make a HP bar for my player
im making an rpg game and need an hp bar. how do i do this?I made one for you
- jaythunderbird
-
15 posts
how do i make a HP bar for my player
Okay i gotcha bro, (this only works for the main player.)
first create a sprite.
make it like a hp bar with full hp.
now make many costumes (as much as you want the hp), lowering the hp bar every costume.
once you get to last costume, make sure it has no hp.
lastly, name it from top to bottom.
ex. 5 for the highest hp (how high you want the hp)
and 0 for the lowest
now place the hp bar wherever you want to put it.
create a new variable called hp for all sprites
then code this.
and in a different sprite you can do this
first create a sprite.
make it like a hp bar with full hp.
now make many costumes (as much as you want the hp), lowering the hp bar every costume.
once you get to last costume, make sure it has no hp.
lastly, name it from top to bottom.
ex. 5 for the highest hp (how high you want the hp)
and 0 for the lowest
now place the hp bar wherever you want to put it.
create a new variable called hp for all sprites
then code this.
as many if statements as the hp.
and in a different sprite you can do this
important:
Last edited by jaythunderbird (June 1, 2022 16:46:07)
- Huckleberry256
-
100+ posts
how do i make a HP bar for my player
Here's a script I used for something similar in one of my games.
1. Make costumes for the health bar. Each costume will represent a certain percentage of the maximum health. For the costumes' names, just put the percentage for that specific costume. The empty costume should be 0 and the full costume should be 100. Keep the increments' amounts consistent. (You'll need that later)
Example list of costumes: “0” (empty health bar), “25” (1/4 full), “50” (halfway full), “75” (3/4 full), “100” (completely full); increment is 25
2. Make this script in the health bar sprite. (Pay attention, the order of the blocks is important.)
Hope this helps! Feel free to ask if you have any questions!
1. Make costumes for the health bar. Each costume will represent a certain percentage of the maximum health. For the costumes' names, just put the percentage for that specific costume. The empty costume should be 0 and the full costume should be 100. Keep the increments' amounts consistent. (You'll need that later)
Example list of costumes: “0” (empty health bar), “25” (1/4 full), “50” (halfway full), “75” (3/4 full), “100” (completely full); increment is 25
2. Make this script in the health bar sprite. (Pay attention, the order of the blocks is important.)
Hope this helps! Feel free to ask if you have any questions!
Last edited by Huckleberry256 (June 1, 2022 17:17:07)
- hiiamshrek
-
66 posts
how do i make a HP bar for my player
im making an rpg game and need an hp bar. how do i do this?
Try this:
a take damage feature right here:
Last edited by hiiamshrek (June 1, 2022 19:52:54)
- Discussion Forums
- » Help with Scripts
-
» how do i make a HP bar for my player