Discuss Scratch

coco3021
Scratcher
21 posts

Pen Health Bar Trouble

Hiya! I am having trouble creating a pen health bar. I am trying to make clones of the health bars, which are written in pen. I have never done a project with pen before, so I don't know if I am doing something wrong. Additionally, one of the people clones are not recording their x and y stats, but I am sure I can figure that out. I would really appreciate help!
Here is the link:
https://scratch.mit.edu/projects/1119397320/
bsteichman
Scratcher
500+ posts

Pen Health Bar Trouble

I'm not sure what purpose, your second sprite serves, maybe delete that if you're not using it. also for your health bars, you do not need to use clones to draw all the health bars, just loop through all the positions in the list. also have a list for health not just one variable because your clones do not all share the same health.

replace the code in your sprite 3 with this:
when green flag clicked
hide
forever
draw health
end

define draw health
clear
set [clone id 2 v] to [0]
repeat (4)
change [clone id 2 v] by [1]
set [width v] to (item (clone id 2) of [health v] :: list)
rest of your old draw health code :: grey
end
everything else could probably be deleted in that sprite. with that i'll leave it to you to fill the health list and update it with the clones
coco3021
Scratcher
21 posts

Pen Health Bar Trouble

bsteichman wrote:

I'm not sure what purpose, your second sprite serves, maybe delete that if you're not using it. also for your health bars, you do not need to use clones to draw all the health bars, just loop through all the positions in the list. also have a list for health not just one variable because your clones do not all share the same health.

replace the code in your sprite 3 with this:
when green flag clicked
hide
forever
draw health
end

define draw health
clear
set [clone id 2 v] to [0]
repeat (4)
change [clone id 2 v] by [1]
set [width v] to (item (clone id 2) of [health v] :: list)
rest of your old draw health code :: grey
end
everything else could probably be deleted in that sprite. with that i'll leave it to you to fill the health list and update it with the clones
Thanks a million! This really helps!
cosmosaura
Scratch Team
1000+ posts

Pen Health Bar Trouble

Topic closed due to necroposting.

Powered by DjangoBB