MZ4
January 13, 2019, 2:47am
1
Is “setDragLock” working in Phaser3? I am trying to implement single axis dragging like in match 3 games, I can’t find “setDragLock” in the documentation so i’m using
box.on('drag', function (pointer, dragX, dragY){
if(dragX>dragY){this.x = dragX;}
else {this.y = dragY;}
}
But this breaks as the object is dragged further away.
1 Like
sudhir
January 13, 2019, 5:44am
2
Here is one way to do this:
this.input.setDraggable(box)
this.input.on('drag', function (pointer, gameObject, dragX, dragY) {
gameObject.x = dragX;
});
This will only move the box on x axis.
1 Like
roku
June 21, 2022, 10:20pm
3
sudhir:
this.input.on('drag', function (pointer, gameObject, dragX, dragY) {
gameObject.x = dragX;
});
Does not work.
At least in my case.
P.S.
I’m using mouseSpring .