Clones can make everyone's life easier, if you have an object you need 20 of, but you don't want to copy and paste and have 20 identical objects clogging up the editor. But, clones only help if you know how to use them.
My sand castle builder used a lot of clones, so I'll be taking examples from that. (Because if you tried to brave that code yourself, you’ll be walking in circles for eternity. My editor barely makes sense to me.)
Clones have a few individual values. Speed, x position, y position, angle, and invisibility can be used. Speed is undetectable for clones not moving, and therefore what many people use. But if you have a game where you need to catch clones falling, you shouldn't use speed. If the individuality of your clones depends on the speed of them, and you need them falling at different speeds, more likely than not, you're going to hit a wall.
Generally, if you have falling clones, when one of them bumps the catcher, they all disappear. And that’s definitely not what you want to happen.
This, besides the code that controls the catcher and the code that controls the falling of the clones, is the main code of this simple program. And this code is where the problem lies.
The circled rule is causing the problem. When you play this, if just one of these clones bumps the catcher, they all disappear. Because they are all “Circle”, so if one of them bumps the catcher, the rectangle, “Circle” bumps “Rectangle”, and the rule is true.
However, if you keep this rule, but add to it several check once if blocks, catching the clones individually becomes possible.
Now, the clones are “Sand”, and the catcher is “Pail”. It is practically exactly like the other code I showed above, but with one important difference.
The check once ifs use the clones’ individual x and y positions to see if they are where the catcher is. If they’re not, then they won’t become invisible. Read that again. If they’re not, then they won’t become invisible. This is the whole point, and therefore, creates the individuality of the clones necessary. Also in those check once ifs, you can increase the score, or decrease it. (What I erased in that picture was just a complicated increase value, by the way.)
However, depending on the size of your catcher, the circled numbers above will not work. You will need to experiment to get the proper numbers. The taller your catcher, the higher the number next to the y needs to be. The wider the catcher, the larger the positive number, and the lower the negative number, next to the xs need to be. This part is really just trial and error, until you find what works.
Also, these are for when the clones are coming from the top. You can also edit it so it works from the sides or the bottom, but you will have to edit the numbers accordingly. Ask below if you need help with that!
But when you finish, you have clones that disappear individually when they are caught!
Sometimes you need clones to multiple individual things, and you can’t use x position or y position, and you’ve already used speed. Problem is, you need it to be a specific size, or at a specific angle, or at a specific invisibility. What do you do?
This is where the lovely addition/subtraction operator comes in! So, you have a set size block. The size you want is 500, but you only want the clone to appear when a value equals a certain number, whatever the value was when the object was cloned. This method can be useful for making screens and anytime you need to keep the amount of a value at the time of an object’s cloning.
Basically, the number in the addition operator is the original size you want it to be. If you wanted the clone to be at a size of 325, set that number to 325. Don’t put a random operator in that section. DO NOT. There will be no simple way to correctly catalogue the value and the number it should be set to to make the check once if true. In the value part of the addition operator, put the value you are going to check.
In the check once if else (or check once if, depending on what you need for the project), you need to put: check once if (value you used above) = object’s size as a percent - (original size you wanted), and in the check once if, you put whatever you want to happen!
This method isn’t flawless, but as long as it doesn't have to be extremely exact, this should work for you (when I found this method I was just too sick of experimenting to come up with a more exact way, so sorry). This method also works best when the clones are being created one at a time. If they are cloned when _____ is tapped, when _____ is swiped, when _____ bumps _____, or a similar rule, this is very helpful! If not, you will have to increase the values to whatever you want them to be at the time of cloning, which is not great for cataloguing values at the time of cloning, or screens. You can play around with this to figure things out, and you will probably need to to get it to work, but this is just a suggestion, because, let’s face it, clones are confusing. (And this is probably extremely confusing as well. If you have any ideas to make it clearer, please comment!)
I hope this helped! If you need help, with clones in your own project or with understanding this how-to, comment below! Also comment if you have something to add, something to correct, or suggestions to make this how-to better!
(I thought of making this because of @Rainboom and @smishsmash's collab Falling Stars. I was randomly topic surfing, read through it, and saw they had a clone problem. They had came up with a solution by the time I saw the topic, but I got the idea to make this.)