Naming a Cloned object

I need help, everytime I clone they don’t have a name here’s what i’m using

if(gameover === true){
if(door1 === false){
const doorclone = this.clone()
door.x = 685.659;
door.y = 313.803;
door1 = true;
}
}

i dont know really how to name objects via code, but i think if you can if you use “if(this.isClone){}”, then you can at least get clones via code. also, i was digging though the paper.js documentation, and i found a few items that look… rather, interesting. maybe this can help?


if needed, here is a link to the documentation.

if(gameover === true){
    if(door1 === false){
        const doorclone = this.clone()
        door.x = 685.659;
        door.y = 313.803;
        door1 = true;
    }
}

for starters, you have doorclone as the name of your clone while you are modifying the coordinates of door.

another thing, i think after you exit the inner if statement, doorclone is lost. it only exists for as long as you are in that inner if statement, then the variable is gone (the clone itself should still be there).

you can put your clones in an array (you allready have object.clones) and refer to them as array members
no need to name them

1 Like