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

#1 2012-10-11 12:56:12

tambetm
New Scratcher
Registered: 2012-10-11
Posts: 1

Touching event

Hi!

Can somebody explain me, why there is no "when touching SpriteX" control block in Scratch?

I'm finding myself always writing code like this:

when gf clicked
forever if <touching [SpriteX]?>
  doSomething
end
This looks more intuitive to me:

when [SpriteX] clicked
doSomething
but instead of "clicked", it would say "touched this".

There must be a good reason why they designed it such way and out of curiosity I would like to know.

Thanks,
Tambet

Offline

 

#2 2012-10-11 13:06:36

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Touching event

This would probably be more efficient if you have multiple detection scripts for multiple sprites:

when gf clicked
forever
if (touching [sprite v]?)
do something
end

if (touching [sprite2 v]?)
do something
end

if (touching [sprite3 v]?)
do something
end
end
But it does seem kind of silly to not have one. But it would probably be less strain on Scratch if you do it the above way. That way your aren't running a separate script for every single sprite detection.

Offline

 

#3 2012-10-12 01:39:19

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: Touching event

You could use the above code, but if you modify Scratch, you can add a "when <>" hat block. You can use that if you are not uploading the project to the scratch website.  If you are going to upload to the Scratch website, you need something like the above, which is slower.


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

Board footer