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

#1 2012-06-19 10:44:54

pipercubjl
Scratcher
Registered: 2010-05-20
Posts: 73

Help with tagging sprites?

I would like to know if tagging sprites is possible. In other words, checking for collisions with any sprite with a certain tag. This would help a lot.



For instance:


If touching: Sprites tagged with "Wall"


Hope I make sense  smile


http://scratch.mit.edu/static/projects/pipercubjl/2621398_med.png  http://scratch.mit.edu/static/projects/pipercubjl/2634368_med.png
        Crypt            Pixel Lands

Offline

 

#2 2012-06-19 10:51:08

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Help with tagging sprites?

Yes, it's possible, like this:

if <<<<touching [wall1 v]?> or <touching [wall2 v]?>> or <touching [wall3 v]?>> or <touching [wall4 v]?>> //All of your wall sprites
 whatever
end

Last edited by SciTecCf (2012-06-19 10:51:43)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#3 2012-06-19 10:57:42

pipercubjl
Scratcher
Registered: 2010-05-20
Posts: 73

Re: Help with tagging sprites?

I meant a way that would take less space and time. Thanks though!


http://scratch.mit.edu/static/projects/pipercubjl/2621398_med.png  http://scratch.mit.edu/static/projects/pipercubjl/2634368_med.png
        Crypt            Pixel Lands

Offline

 

#4 2012-06-19 11:29:09

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Help with tagging sprites?

Sorry, I don't know of an easier way. You might wanna experiment with lists, though.  wink


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#5 2012-06-19 11:49:31

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

Re: Help with tagging sprites?

You could name all of your sprites "name" #.  Then use this script (idk if it'll show up correctly though):

forever
set [name v] to (0)
repeat (length of [names v]) //make a list with all the possible names
change [name v] by (1)
set [# v] to (0)
repeat (5) //or whatever number of sprites each tag has
change [# v] by (1)
if <touching (join (item (name) of [names v]) (#))?>
  broadcast (name) //Have a "When I receive" for each tag
end
end
end

Last edited by AtomicBawm3 (2012-06-19 11:50:38)


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

Offline

 

#6 2012-06-19 12:04:38

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Help with tagging sprites?

AtomicBawm3 wrote:

You could name all of your sprites "name" #.  Then use this script (idk if it'll show up correctly though):

forever
set [name v] to (0)
repeat (length of [names v]) //make a list with all the possible names
change [name v] by (1)
set [# v] to (0)
repeat (5) //or whatever number of sprites each tag has
change [# v] by (1)
if <touching (join (item (name) of [names v]) (#))?>
  broadcast (name) //Have a "When I receive" for each tag
end
end
end

I don't think the

 <touching (join (item (name) of [names v]) (#))?>
is possible.

Offline

 

#7 2012-06-19 12:10:44

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Help with tagging sprites?

It is, I just tried it. Just like Broadcast (join (blah|blah)) works too.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#8 2012-06-19 12:49:28

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Help with tagging sprites?

AtomicBawm3 wrote:

You could name all of your sprites "name" #.  Then use this script (idk if it'll show up correctly though):

forever
set [name v] to (0)
repeat (length of [names v]) //make a list with all the possible names
change [name v] by (1)
set [# v] to (0)
repeat (5) //or whatever number of sprites each tag has
change [# v] by (1)
if <touching (join (item (name) of [names v]) (#))?>
  broadcast (name) //Have a "When I receive" for each tag
end
end
end

I KNEW IT! Lists ARE the answer!  big_smile


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

Board footer