Discuss Scratch

bobbyjoejrfred
New Scratcher
2 posts

Counting the number of sprites

Is there any way to count the number of a certain sprite? Like if you have a single tree sprite with multiple costumes can you count how many trees have costume 1, how many have costume 2 etc and store that in a list?
Mole_Gaming
Scratcher
100+ posts

Counting the number of sprites

There's no variable for that, but you could make the clones change a variable or item in list whenever they are created or change costume.
set [trees v] to [0 ]
set [oak trees v] to [0]
when I start as a clone
change [trees v] by (1)
if <(costume #) = [1 ]> then
change [oak trees v] by [1]
end
Maybe something like this?
asivi
Scratcher
1000+ posts

Counting the number of sprites

Is your question about clones?
asivi
Scratcher
1000+ posts

Counting the number of sprites

I hope that this example can help you.
Greets.
BojanVeljkovski
New Scratcher
1 post

Counting the number of sprites

Hello can someone help me …. I need 4 sprites to come and say 1 and make some song, then come second sprite and say 2 and make some song , then come sprite 3 and say 3 and make some song, then come sprite 4 and say 4 and make some noise, then come sprite 1 and say 5 and make some song……
http://prntscr.com/cvgcby -for first sprite
http://prntscr.com/cvgche -for second sprite
http://prntscr.com/cvgcng -for third sprite
http://prntscr.com/cvgct4 and fourth sprite

Can someone help me how i can do that.
asivi
Scratcher
1000+ posts

Counting the number of sprites

BojanVeljkovski wrote:

Hello can someone help me …. I need 4 sprites to come and say 1 and make some song, then come second sprite and say 2 and make some song , then come sprite 3 and say 3 and make some song, then come sprite 4 and say 4 and make some noise, then come sprite 1 and say 5 and make some song……
http://prntscr.com/cvgcby -for first sprite
http://prntscr.com/cvgche -for second sprite
http://prntscr.com/cvgcng -for third sprite
http://prntscr.com/cvgct4 and fourth sprite

Can someone help me how i can do that.



when green flag clicked//1st sprite
set [counter v] to [1]
..stuff...::grey
play sound [ v] until done
broadcast [next v]
when I receive [next v]//2nd sprite
if <(counter) = [1]> then
set [counter v] to [2]
..stuff...::grey
play sound [ v] until done
end
broadcast [next v]

//Do the same for others sprites

Please, the next time you need some help create a topic of your own.
Greets.

Last edited by asivi (Oct. 17, 2016 16:49:14)

stacejo
Scratcher
2 posts

Counting the number of sprites

how do you know how many sprites you have?

Powered by DjangoBB