Hi there. i try to use Drag for my movement controll but i am not sure how to get it right. I don’t want to add a variable but instead use the object “basket” to be clicked and dragged.
this.basket = this.add.image(200, 250, 'basket').setInteractive();
this.basket.scaleX=.5;
this.basket.scaleY=.5;
this.input.setDraggable('basket');
// The pointer has to move 16 pixels before it's considered as a drag
this.input.dragDistanceThreshold = 16;
this.input.on('dragstart', function (pointer, gameObject) {
gameObject.setTint(0xff0000);
});
this.input.on('drag', function (pointer, gameObject, dragX, dragY) {
gameObject.x = dragX;
// gameObject.y = dragY;
});
this.input.on('dragend', function (pointer, gameObject) {
gameObject.clearTint();
});