Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I generate a sprite randomly?
- JennDaRandom
-
New Scratcher
2 posts
How do I generate a sprite randomly?
I'm making a game that has to generate different boxes out of a tube, but I'm stuck on that part. And, if it's not too much to ask, I also want to switch the costumes so it looks like different presents are generating as well. Any help?
- NilsTheBest
-
Scratcher
1000+ posts
How do I generate a sprite randomly?
If I understand your question correctly, you could easily do this:
when I start as a clone
switch costume to (pick random (1) to (...))
rest of the code :: grey
Last edited by NilsTheBest (Dec. 8, 2018 15:21:56)
- JennDaRandom
-
New Scratcher
2 posts
How do I generate a sprite randomly?
If I understand your question correctly, you could easily do this:Thanks! But it's spawning in different places, do you know how to make it spawn from one place only, like if it was shooting out of a tube?when I start as a clone
switch costume to (pick random (1) to (...))
rest of the code :: grey
- deck26
-
Scratcher
1000+ posts
How do I generate a sprite randomly?
Clones are created at the same position as the parent (the sprite or clone that creates them with the exception that if spriteA creates a clone of spriteB it will be created at the position of spriteB). So spawning in one place shouldn't be difficult as long as you avoid clones creating clones.
- Minecraf_player
-
Scratcher
33 posts
How do I generate a sprite randomly?
and you could use this block
when I start as a clone
go to x: (0) y: (0)
Last edited by Minecraf_player (Dec. 9, 2018 12:08:39)
- BrycenAF_10
-
Scratcher
1 post
How do I generate a sprite randomly?
Ok how do I make a sprite spawn like 1 out of 10 games I play.
- zeiraph
-
Scratcher
100+ posts
How do I generate a sprite randomly?
Ok how do I make a sprite spawn like 1 out of 10 games I play.this is a very old post, over 7 years old, please don't post on old topics, doing such is called necroposting, and makes it harder to find others who need help. make your own post next time
- Discussion Forums
- » Help with Scripts
-
» How do I generate a sprite randomly?





