Get a GameObject by it's ID

Hi guys

Is it possible to get the whole GameObject (sprite) by just having it’s ID? Where would I look for it?
I have a method that receives said ID, and needs to operate then with the object.

Thanks.

Hello @Tico1711

If you gave your every sprite a name it’s possible to use something like this:

create() {
    const child = this.children.getByName('string-name');
}

Since the scene’s children element is a DisplayList element which extends Phaser.Structs.List this.children has a method getByName which give’s you to ability to find childs with name :slight_smile:

2 Likes