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

#1 2011-05-12 23:21:51

liebermary
New Scratcher
Registered: 2011-05-12
Posts: 2

How to freeze game when sprite #1 touches #2 without stopping script?

Basically I am trying to make a chase game in which a sprite is caught says something, then switches to the next costume. There are other sprites in the game as well who are catching us (the sprite we are controlling). So when Sprite #1 (us) catches Sprite #2, how do I freeze the game temporarily when Sprite #2 says something?

Offline

 

#2 2011-05-12 23:28:49

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How to freeze game when sprite #1 touches #2 without stopping script?

I would recommend setting the variable "Sprite2 caught?" to "yes" when this happens. In all other sprites, have the scripts run only if the variable is "no". Another way would be to use a broadcast. Did that help?

Offline

 

#3 2011-05-12 23:41:54

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to freeze game when sprite #1 touches #2 without stopping script?

To clarify what scimonster said

You should have a forever loop in every sprite, ok?
The first thing inside that script should be an if block that tests if a certain variable (in this case, sprite2 caught) is yes or no.  The scripts for all of your sprites should run only if it equals no.  In the sprite you use you do not need this if loop.  All you need is a loop that says something like:
If touching sprite1
   set (touching) to (yes)
   say  (you caught me) for (4) seconds
   switch to costume (caught)
   wait until (condition you want to be for new game to start)
end

If this doesn't work, please post the project and I will attempt to make sure everything is right and that we can find a way to make it work.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2011-05-18 02:18:12

liebermary
New Scratcher
Registered: 2011-05-12
Posts: 2

Re: How to freeze game when sprite #1 touches #2 without stopping script?

http://scratch.mit.edu/projects/liebermary/1792623

Here is the game.... could you also help me that once all the costumes of the sprites: meme1 & meme2, are gone through the game will end?

Thanks for the help!

Offline

 

#5 2011-05-18 03:55:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How to freeze game when sprite #1 touches #2 without stopping script?

liebermary wrote:

http://scratch.mit.edu/projects/liebermary/1792623

Here is the game.... could you also help me that once all the costumes of the sprites: meme1 & meme2, are gone through the game will end?

Thanks for the help!

Instead of:

[blocks]<if><< <touching[ Troll1  <or> <touching[ Troll2  >>[/blocks]

Do:

[blocks]<if><< << <touching[ Troll1  <or> <touching[ Troll2  >> <or> << <( ([costume #] of [Meme1]) <=> 5 )> <and> <( ([costume #] of [Meme2]) <=> 5 )> >> >>[/blocks]

That way if it touches wither troll or both memes are at costume5, it will end.  smile

Last edited by scimonster (2011-05-18 03:55:38)

Offline

 

Board footer