npm i --save phaser3-swipe-plugin
# Or
yarn add phaser3-swipe-plugin
- Import
import SwipePlugin from 'phaser3-swipe-plugin'
- Add to config (GameConfig)
plugins
property.
...
plugins: {
global: [
{
key: 'SwipePlugin',
plugin: SwipePlugin,
start: true,
// custom options
data: {
// you can give your value for min offset
offset: 100
}
}
]
}
...
- Add event listener.
game.events.on('swipe', dir => {
// 'up', 'right', 'down' or 'left'
console.log(dir)
})
Tested on Phaser 3.15.1
.