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

#1 2009-10-22 04:41:51

x_andrew_xx
Scratcher
Registered: 2009-10-13
Posts: 8

How to fix this?????

Hey guys how do i stop i script when a sprite hides? Okay here's what i'm doing. I am making a shooting game. I made this sprite shoot every 3 seconds and when it gets hit by another sprite, it hides. But the problem is, the bullet wont stop shooting, how can i fix this?

Offline

 

#2 2009-10-22 05:05:00

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: How to fix this?????

If the bullet touches the sprite that hides you can us "repeat until" and the "touching sprite that hides"

you could use a variable so when the sprite gets hit it changes the variable so that the bullet sprite stops.   
You put an if statment in the bullet sprite
like this "IF Variable = 1,  set variable to 0, stop script"

You then put a statment in the hiding sprite like this "(when the sprite hides statment) set variable to 1". <-- all you do is add this statment to the existing statment


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#3 2009-10-22 08:55:20

steppenwulf
Scratcher
Registered: 2009-07-23
Posts: 1000+

Re: How to fix this?????

Try this andrew. Put this on all of the sprites except for the one that is shooting.

<when green flag clicked>
<forever>
<if><touching[
<broadcast[ die


Put the below script on the bullets themselves:

<when I receive[ die
<stop script>


I'm graduating HS this April and going to college in the Fall.

Offline

 

#4 2009-10-25 09:45:43

TheSaint
Scratcher
Registered: 2008-11-04
Posts: 1000+

Re: How to fix this?????

steppenwulf wrote:

Try this andrew. Put this on all of the sprites except for the one that is shooting.

<when green flag clicked>
<forever>
<if><touching[
<broadcast[ die


Put the below script on the bullets themselves:

<when I receive[ die
<stop script>

That won't work steppun, the stop script button only works for the script it is in.

Put that stop script block directly after the hide block in your script. That should work.

Offline

 

#5 2009-10-25 09:58:28

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: How to fix this?????

Try this:
[blocks]
<when green flag clicked>
<forever>
<if> <touching[ Whatever Kills You]
<hide>
<stop script>
<end>
<end>
[/blocks]

Last edited by demosthenes (2009-10-25 09:58:48)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

Board footer