Touchscreen player control with animation?

Hello, I’m making a mobile game that needs the touchscreen to move the player (swiping right/left). How do I achieve that?
And how to play animation based on player move direction? I already have ‘idle’, ‘walk_left’, and ‘walk_right’ animations.

Not sure what you mean by swiping right/left.
If it is swiping the screen then you can use the below code.

this.input.on('pointerup', function (event) {
    var dx = event.upX - event.downX;
    var isMoveLeft = dx > 0 ? false : true;
    if (isMoveLeft) console.log('go left');
    else console.log('go right');
}, this);