Hi I’m Dog Icing! Recently a lot of people have been asking for a way to refer to clones so I’m going to show you a way that I use in my projects to refer to clones.
- We’re gonna be using Last touch x and last touch y variables, however these aren’t redefinable, meaning that once tapped the function will execute forever. So, we’re going to create an object purely for fixing this problem. You can call this anything. In this example I’m going to call it X&Y.
Now add the following code :
When (My Ipad)* is tapped {
Set game variable** (X) to (Last touch X)
Set game variable** (Y) to (Last touch Y)
}
That’s it for this object. Now to the more complex code.
- Go to the clone you want to use this on (this can be used on many clones at once) and add the following code note that when clone index = (number) is always executing so there is no need for
“repeat forever”).
Now we’re going to check whether the last touch is within the borders of the clone. To do this we’re going to use x and y positions. X and Y positions say give the x and y position of the center of a clone/object so we’ll add+ self width ÷ 2,- self width ÷ 2,- self height ÷ 2,+ self height ÷ 2. These will give us the borders of the object/clone.
After you’ve got thecheck once ifsorted, add your code and then, define the x & y to a location off the stage so objects can’t be affected/tapped there. In this example I’ve chosen -1 because it’s the first off the canvas and it’s the lord lol. Note: I think it is important to tell you that 0,0 is the lower left corner and anything less is off the stage, same as 100000, 100000 unless you’ve got a screen of 100000,100000. No matter the size of a screen, 0,0 or less will always be off the stage.
Check once if (X) > ((self x position) + ((self width) ÷ 2)) and (X) < ((self x position) - ((self width) ÷ 2)) and (Y) > ((self y position) + ((self height) ÷ 2)) and (Y) < ((self y position) - ((self height) ÷ 2)) {
[add your code to be executed]
Set game var (X) to (-1)
Set game var (Y) to (-1)
}
Now, keep in mind that you can now just copy and paste this code for when tapped for any clone. ![]()
* if you’re using an iphone it’ll be when my iphone is tapped
** this must be a game variable to be accessible by different objects and clones. You could put ((xy object name) variable name) but game variables are much quicker.
Please let me know how you feel about this topic, constructive criticism is appreciated, and whether it worked.
- Dog Icing


check the second image… that should explain it