Discuss Scratch

CodeKing_11
Scratcher
100+ posts

create a duplicate of sprite

Let's say you were working on a sprite with a LOT of costumes of different items, and you plan to duplicate the sprite 10 times. You want to make it move and bounce around while switching costumes, and if 2 sprites interact with one another, if they are different sprites, a random number is picked and that decides which sprite has to change costumes to the other's costume. You perfect the code, and it looks good! You are about to press the share button when you think of another item costume to add to the game. You have to either make a new costume on 1 and copy and paste it onto the others or delete all but 1 sprite, add the costume to that sprite, and duplicate the sprite again. Just a small inconvenience, right? Wrong. You finish adding that item when suddenly, you think of another. And another! And another until you've spent a long time focusing on just adding new costumes, and when you publish the game and update it, you have to always make more of the costumes for more items. There is a seemingly infinite amount of costumes you can add, and your wasting time you could use to improve the game by just copying and pasting different costumes of deleting sprites to duplicate them again.

Most people, in this situation, would try to use clones for help, thinking it couldn't be that hard. So let's say you try to do that. Now all you need to do is add a costume whenever, no copying or deleting needed! However, while trying to adapt the code for the clones to work, you end up finding out exactly why it feels too good to be true. Not only do you have to try to detect the clone's x and y and the costume, along with somehow assigning each their own number with the same code, but if that's not hard enough as it is, you ALSO need to address what happens when 2 clones collide at the same time as 2 OTHER clones, basically making the randomness almost impossible if the constant list updating wasn't enough. And even if it were possible, a simple game being made by a new scratcher would turn from a simple first game to a time consuming and maybe even abandoned project. And some people don't want huge blobs of code as their first game they ever made in scratch.

At the moment, I am struggling with a similar thing. All the code is great and then one small problem turns the game upside down This is why I thought of this idea of copying a sprite. This would be kind of like the clone feature, except it's literally a duplicate sprite of the original sprite the code was on, with the exception of the duplicate sprite all the code in it, although it would not be activated until the block shows up. It would show up as SpriteName(1) and could be used for things you can't already use with clones, such as detecting x and y coordinates and costumes, and basically just act like a normal sprite, but just appearing at the time the block is used during the game. This would make when green flag clicked it still technically when the green flag is clicked, because it didn't exist before the green flag was clicked.

Let's put this in the context of this example game. If we use the Duplicate Sprite block, the user can detect everything on the duplicated sprite, and it would save many minutes of time.

This is what the block could look like

duplicate sprite [ v]
There could also be one for if it was just duplicated for more uses, like this but switch clone for duplicated:
when I start as a clone

As i didn't really look through the topics for this, I am aware that I might be using a topic that was already suggested, but I really wanted to put this out there for people to see and maybe even ST adding this in the near future!

Last edited by CodeKing_11 (March 24, 2025 22:23:33)

unknown2467
Scratcher
100+ posts

create a duplicate of sprite

when green flag clicked
set [Clone ID v] to [0] // local
repeat (10)
change [Clone ID v] by (1)
create clone of [ v]
end

when I start as a clone
if <(Clone ID) = [1]> then
...
else
...
end
Put some list collisions or calculations and you get clone collisions.
CodeKing_11
Scratcher
100+ posts

create a duplicate of sprite

unknown2467 wrote:

when green flag clicked
set [Clone ID v] to [0] // local
repeat (10)
change [Clone ID v] by (1)
create clone of [ v]
end

when I start as a clone
if <(Clone ID) = [1]> then
...
else
...
end
Put some list collisions or calculations and you get clone collisions.
Nice! Nevermind then!

Powered by DjangoBB