What to extend to allow drag

I have a class where I am building a complex object consisting of multiple sprites. I want to have the object generated by it draggable. I have the set/get for both x and y implemented. When I call setDraggable() on such an object I get the following error: Uncaught TypeError: Cannot set property ‘draggable’ of undefined

My assumption is that I need to make it interactive first by calling a setInteractive(), but since it is a custom made object I don’t have such a method. I probably need to extend a certain class to have this functionality, but don’t know which one.

My current class looks something like this:

class MyComplexObj {
    constructor(scene) {
        scene.add.sprite(...);
        scene.add.sprite(...);
        scene.add.sprite(...);
    }

    set x(pos) {
        // set x for all sprites
    }

   set y(pos) {
       // set y for all sprites
   }
}

Maybe have you class extend Phaser.GameObjects.GameObject
Then with you instance of MyComplexObj you can call .setInteractive()

Can you use a Container instead?

This partially worked. Extending GameObject no longer triggers the error and I can call setInteractive().
However, I still can’t drag the element. I think I know why though.
Since this is a custom made object, it does not know what are the borders, so it does not know when I actually click on it.
Investigating further, but I believe I am on the right path. Thanks

Pass a hit area to setInteractive(). Or extend Zone instead.

Thanks. Will have to look into how to provide the sprite that is the background as the hit area.