Help with "clone()"

I was trying to recreate “The Dinosaur Game” just for fun, and I wanted to use “clone()” but I don’t know how to use it. Does anybody know how to use it?

Hello @DesmondE!

You can use the clone() function to create a clone of a wick object.

“this.clone()”

Usage:
this.clone() // clones the current wick object
A.clone() // clones “A”

If you want to name a clone, you can run:

const name = this.clone() // declares “name” to this.clone() and creates a clone to the current wick object.

There are more tutorials/references on the wick forums if you are interested.
There is also the wick editor reference page.

Good luck on “The Dinosaur Game”. :+1:

Do you know how to make the clone spawn in a specific location?

say you have a clip named baseClip
newClip = baseClip.clone();
newClip.x= 5;
newClip.y= 10;

tadaaaa you have a new clip at coords (5, 10)

Just to add on to what blurredPixels and CosmicKnight1 mentioned, you can also use the “this.isClone” condition to know if the object is a clone or if it’s the original clip… example:

if(this.isClone){
this.x=5;
this.y=10;
}

This is useful to use when you want clones to act differently from the original clip or vice versa.
Examples when this can be used:

  • Cloning the original clip without having the clones cloning themselves.
  • Removing clones without removing the original clip.
2 Likes