How on earth do clones work

#1

i’m making a game, and I want to make it so that a new piece spawns after one piece is placed, so i’m using the clone thing. when i tried it, it became foggy, so i assume it overlayed on the same pixels. I had absolutely no clue what i could do with it, so i tried putting in (bob) and (“bob”) to see if i could get it back with bob.x = 100;… and sadly it didn’t turn out as what I hoped. I think (bob) was said to be undefined, and (“bob”) was fine, but bob.x = 100; didn’t work. neither did this.bob.x. i even tried printing out all the clones, and i looked in the console, and it constantly printed “Wick.clip” until i stopped the project.

I NEED HEPP PLEZZ TANK U IN ADVANCE

0 Likes

#2

Hey there!

Currently, cloning is notoriously buggy, so the example I will show you is not on the website yet. But it works! (Mostly!)

CloningExample.wick (13.8 KB)

In the button in the example, you can see the code for cloning.

First, you create a clone of an object like so:

var newperson = person.clone();

Then, you can change the clone however you want (in this example, it puts the clone in a random position):

newperson.x = random.integer(0, 720)
newperson.y = random.integer(0, 405)
newperson.rotation = 0;

Let me know if you need any help, or if you find any bugs with cloning~!

1 Like

#3

Oh, it seems I used the function completely wrong. Thanks for pointing that out, I’ll try using it that way.

0 Likes