Pages: 1
Topic closed
Hey guys,
I made an action fighting game,
I've made a variable which represents the health of a fighter(sprite),
what should i do..so that as soon as the variable becomes zero.the script ends??
Offline
How about:
<when green flag clicked>
<forever>
<if><( <{ Variable }> <<> 1 )>
<stop all>
<end>
The reason I used "less than one" not "equals zero" is that Scratch might not detect the exact moment that you get zero, which could mean that you get negative lives. But with my method, it works. Hope this helps
Offline
^
and also if you want a "you died" message, then use broadcasts.
[blocks]
<when green flag clicked>
<forever if> <( Health <<>1 )>
<broadcast[You died message
<end>
[/blocks]
And then to all your sprites
[blocks]
<when green flag clicked>
<show>
<when I receive[ You died message
<hide>
[/blocks]
Then create another background called die message. Chuck some "You died" text on it or whatever. (I won't be surprised if you are asleep reading this now )
On the background put:
[blocks]
<when green flag clicked>
<switch to background[ Normal background
<when I receive[ You died message
<switch to background[ You died background
[/blocks]
Like that. Quite simple.
Offline
Topic closed
Pages: 1