Discuss Scratch

tm0054
New Scratcher
2 posts

Using sprites more than once on one stage?

I'm new to Scratch and still feeling my way around.

One question - I am building a little Pac-Man game. The thing I am trying to figure out is how to make the dots work without needing hundreds of duplicate dot sprites. Is it possible to use the same sprite more than once in one stage? It seems like every sprite you import only allows for one instance in the stage.
EZ-Games
Scratcher
1000+ posts

Using sprites more than once on one stage?

Yes, it is possible to use the same sprite more than once in one stage. Instead of making hundreds of dot sprites as you said, you can make clones. To make a clone, it as easy as attaching this block to your script:
create clone of [myself v]

You can choose what you want that clone to do once it's created by simply using this block in the same sprite:
when I start as a clone

This is the script I recommend making when the clone is created (and then, of course, add more blocks if needed):
when I start as a clone
forever
if <touching [Pac-Man v] ?> then
delete this clone
end
end

I hope this helped out in some way, Scratch On!
bakedbread
Scratcher
44 posts

Using sprites more than once on one stage?

EZ-Games wrote:

Yes, it is possible to use the same sprite more than once in one stage. Instead of making hundreds of dot sprites as you said, you can make clones. To make a clone, it as easy as attaching this block to your script:
create clone of [myself v]

You can choose what you want that clone to do once it's created by simply using this block in the same sprite:
when I start as a clone

This is the script I recommend making when the clone is created (and then, of course, add more blocks if needed):
when I start as a clone
forever
if <touching [Pac-Man v] ?> then
delete this clone
end
end

I hope this helped out in some way, Scratch On!
And just a tip - clones keep all the information of their parent when created, but then that data can be edited individually within the clone.
For example, if Sprite1 creates a clone, while wearing costume5 and at (210, -50), then its clone will be wearing costume5 and at coordinates (210, -50).
The same applies to variables marked “for this sprite only” - every clone and the parent will have their own individual value for that variable, and, when a clone is created, its value depends on whatever the parent's value was its creation.
tm0054
New Scratcher
2 posts

Using sprites more than once on one stage?

Thanks for the info!

Interesting so you would still need a lot of code to position all 244 dots around the maze. I suppose you could use a few loops to alleviate some of the grudge work but that seems a little cludgy. Most other game maker programs I've used allow you to put as many instances of an object or sprite on a board as you want.

So many old arcade games have lots of repetitive objects in them.
Starstriker3000
Scratcher
1000+ posts

Using sprites more than once on one stage?

repeat (244)
create clone of [myself v]
next costume
end

when I start as a clone
show
go to x: (item (costume #) of [Dot X v] :: list) y: (item (costume #) of [Dot Y v] :: list)
wait until <touching [Pac-Man v] ?>
delete this clone

In that instance, you'd need 244 identical costumes and 244 items in two different lists (which makes 488 items), but it basically positions all the dots into the locations stored in the two lists, and then the clones delete themselves when they touch Pac-Man. In this scenario, the original sprite will be hidden the whole time, and the clones will show themselves when they're created. Both of these scripts would go inside the Dots sprite, and the first one would fire when the level starts, whether on flag click or a broadcast message.

Last edited by Starstriker3000 (June 5, 2019 16:16:28)

Wahsp
Scratcher
1000+ posts

Using sprites more than once on one stage?

Starstriker3000 wrote:

repeat (244)
create clone of [myself v]
next costume
end

when I start as a clone
show
go to x: (item (costume #) of [Dot X v] :: list) y: (item (costume #) of [Dot Y v] :: list)
wait until <touching [Pac-Man v] ?>
delete this clone

In that instance, you'd need 244 identical costumes and 244 items in two different lists (which makes 488 items), but it basically positions all the dots into the locations stored in the two lists, and then the clones delete themselves when they touch Pac-Man. In this scenario, the original sprite will be hidden the whole time, and the clones will show themselves when they're created. Both of these scripts would go inside the Dots sprite, and the first one would fire when the level starts, whether on flag click or a broadcast message.
You could make this even simpler with variables so you wouldn’t need costumes
set [number v] to (0)
repeat (244)
create clone of [myself v]
change [number v] by (1)
end

when I start as a clone
show
go to x: (item (number) of [Dot X v] :: list) y: (item (number) of [Dot Y v] :: list)
wait until <touching [Pac-Man v] ?>
delete this clone
hani2018
Scratcher
100+ posts

Using sprites more than once on one stage?

You could paste them on to the stage with the copy tool

Powered by DjangoBB