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
}
}