1

I am a beginner in scratch and I am creating a simple project in which there is a sprite and I create clones of that sprite and place them in a pyramid format.

My question - Once I create a clone, how can I move that clone to specific x and y position?

user979189
  • 1,230
  • 2
  • 15
  • 39

4 Answers4

1

If you want to move each clone to a different position, it's rather easy to do this using a variable. Basically, you can change the variable by 1 every time a new clone is created, in a way giving the clone an "ID" until the next clone is created. You can then use this ID to tell each clone where to go.

For instance:

CREATE CLONE OF (MYSELF)  
CHANGE [CLONES] BY (1)

...in one script, and in another:

WHEN I START AS A CLONE  
IF [CLONES] = (1)  
GO TO X: Y:  
ELSE IF [CLONES] = (2)  
GO TO X: Y:

etc.

This allows you to put each clone in a different location. (Afterwards, if you want to move a specific one of the clones, you can use the location of the clone as a unique identifier.)

Mithical
  • 603
  • 1
  • 17
  • 28
1

You can use the set x to () and set y to () blocks to set the x and y positions for clones. If you want to set each clone to an individual position, you can create a "For this sprite only" variable (let's call it z). When green flag clicked, you can set z to 0, then before you create a clone, increase z by 1. The clone will inherit the value for z when it was created. You can create an array called "positions" and add the desired x position of the first clone, then the desired y position of the first clone. Then you can add the desired x position of the second clone, then the desired y position of the second clone, and so on. On the clone itself, you can go to x: (item (((z)*(2))-(1)) of [positions]) y: item ((z)*(2)) of [positions]. This will cause the clone to go to the desired x and y positions for it's z.

You can view an example here: https://scratch.mit.edu/projects/391539263/

Isla
  • 85
  • 9
0

Codes here:

When green flag clicked
create clone of myself

When i start as a clone
goto x: [] y: []

( The [ ] means where you insert number )

My scratch user: https://scratch.mit.edu/users/coco7nut/

-1

Here's a code:

when green flag clicked
create clone of myself
set x to *insert randomised value here*
set y to *insert randomised value here*

Note that x and y is a variable

when i start as a clone
go to x position: x
go to y position: y
Account_2
  • 53
  • 6