This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-06-04 01:28:49

popman000
Scratcher
Registered: 2010-05-19
Posts: 1

Showing Damage on a Life Bar

I want to show how much damage the sprite dealt on a Life Bar. For Example. if sprite 1 damages sprite 2, sprite 2's life bar is lowered. Can anyone help me?

THANKS


PS. I know how to make the Life Bar, but I have troubles with the damage part.

Offline

 

#2 2010-06-04 02:03:55

JTxt
Scratcher
Registered: 2010-05-19
Posts: 100+

Re: Showing Damage on a Life Bar

This depends on how you sense the damage.
Here's one way:
in the p1 sprite:

if p1 attacking
   if touching p2
     change p2health by -1

in the p2 sprite:

if p2 attacking
   if touching p1
     change p2health by -1

But for this way, the p1health and p2health variables would need to be created "for all sprites"

Does this help?
If not, upload and we'll take a look at it.


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#3 2010-06-05 14:37:24

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: Showing Damage on a Life Bar

Well your script is wrong if p2health is the same sprite as p2


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#4 2010-06-05 17:14:31

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Showing Damage on a Life Bar

JTxt wrote:

This depends on how you sense the damage.
Here's one way:
in the p1 sprite:

if p1 attacking
   if touching p2
     change p2health by -1

in the p2 sprite:

if p2 attacking
   if touching p1
     change p1health by -1

But for this way, the p1health and p2health variables would need to be created "for all sprites"

Does this help?
If not, upload and we'll take a look at it.


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer