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

#1 2012-10-31 15:49:40

amyhand
New Scratcher
Registered: 2012-10-31
Posts: 2

Trying to make something happen when one sprite touches another

I have a cat and a dragon.  I entered for the dragon "if touching cat, play drum for .2 beats" but nothing happens when I have the cat touch the dragon.  (My sound is on, and I have tried this with other sprites.)  Am I missing something required to have sprites touch each other be part of a Boolean command?
Thanks!

Offline

 

#2 2012-10-31 17:13:57

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Trying to make something happen when one sprite touches another

for cat:

when gf clicked
wait until <touching [dragon v]?>
play drum (48 v) for (0.2) beats


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-10-31 23:46:15

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Trying to make something happen when one sprite touches another

amyhand wrote:

I have a cat and a dragon.  I entered for the dragon "if touching cat, play drum for .2 beats" but nothing happens when I have the cat touch the dragon.  (My sound is on, and I have tried this with other sprites.)  Am I missing something required to have sprites touch each other be part of a Boolean command?
Thanks!

You need a forever loop around the if.


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#4 2012-11-01 09:12:52

Dsteenson
Scratcher
Registered: 2011-10-12
Posts: 82

Re: Trying to make something happen when one sprite touches another

[scratchblocks]
when gf clicked
forever
if (touching dragon)
Play Drum Beat
end
[scratchblocks/]

(Still learning how to use scratch blocks.)

Offline

 

#5 2012-11-01 09:16:50

Dsteenson
Scratcher
Registered: 2011-10-12
Posts: 82

Re: Trying to make something happen when one sprite touches another

when gf clicked
forever
if (touching dragon)
Play Drum Beat
end
[/scratchblocks]

(Still learning how to use scratch blocks.)

Fixed it a bit.

Offline

 

#6 2012-11-01 13:42:47

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Trying to make something happen when one sprite touches another

Dsteenson wrote:

when gf clicked
forever
if <touching [dragon v]?>
Play sound [Drum Beat v]
(Still learning how to use scratch blocks.)

Last edited by zammer990 (2012-11-01 13:43:36)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#7 2012-11-01 14:34:44

awesomeness321
Scratcher
Registered: 2012-08-10
Posts: 100+

Re: Trying to make something happen when one sprite touches another

amyhand wrote:

I have a cat and a dragon.  I entered for the dragon "if touching cat, play drum for .2 beats" but nothing happens when I have the cat touch the dragon.  (My sound is on, and I have tried this with other sprites.)  Am I missing something required to have sprites touch each other be part of a Boolean command?
Thanks!

It looks like your problem has already been solved, but if this was your script:

when gf clicked//or some other hat block
if <touching [cat v]?>
play drum (48 v) for (0.2) beats
Then it will only check if it is touching the cat at the moment the green flag is clicked.
Use this script (which MoreGamesNow already suggested):
 when gf clicked//or some other hat block
wait until <touching [cat v]?>
play drum (48 v) for (0.2) beats


My newest project:http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=projects&amp;type=newest&amp;return=image&amp;num=1Color:#30F9A5 I am currently http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=onlineStatus&amp;type=text

Offline

 

#8 2012-11-01 14:45:58

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Trying to make something happen when one sprite touches another

awesomeness321 wrote:

amyhand wrote:

I have a cat and a dragon.  I entered for the dragon "if touching cat, play drum for .2 beats" but nothing happens when I have the cat touch the dragon.  (My sound is on, and I have tried this with other sprites.)  Am I missing something required to have sprites touch each other be part of a Boolean command?
Thanks!

It looks like your problem has already been solved, but if this was your script:

when gf clicked//or some other hat block
if <touching [cat v]?>
play drum (48 v) for (0.2) beats
Then it will only check if it is touching the cat at the moment the green flag is clicked.
Use this script (which MoreGamesNow already suggested):
 when gf clicked//or some other hat block
wait until <touching [cat v]?>
play drum (48 v) for (0.2) beats

It sounded like he wanted it to be repeatable, if it does need to happen more than once, use the forever version, if it's only once. use the wait until version


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#9 2012-11-02 03:52:05

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Trying to make something happen when one sprite touches another

In fact, I don't the OP even thought of dragging a hat block. He might have just assembled the detached If statement...


Hai.

Offline

 

#10 2012-11-02 15:23:20

amyhand
New Scratcher
Registered: 2012-10-31
Posts: 2

Re: Trying to make something happen when one sprite touches another

Thanks everybody!  It's fixed.  I needed the "forever."

Offline

 

Board footer