Search code examples
mit-scratch

how to change clone position in the screen at specific x and y positions?


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?


Solution

  • 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.)