README
pixi-gestures
The aim of this project is provide a easy way of getting mouse and touch gestures from a PIXI-JS application.
This project is still in development, and more tools will be added to hopefully help you out on your project
How to use this project
Firstval you have to clone this project and open in a code editor of your choice, and make sure you have node js installed.
Open your terminal at the root project folder and type:
npm install
(this command will make sure all dependences will be installed).
After all dependence is in the right place, lets start the project by typing:
npm start
(this project uses babel + webpack to initialize the application).
By default the project will run at http://localhost:8080/, it can change if you already running an application on port 8080.
For testing, open the browser developer console, and start to drag the mouse, you will see log messages telling what direction you are swaping.
Current working tools
- Swap detection: Detect whem the user swap to a specific direction.
Future tools
- Circle detection: Will detect whem the user draw a circle.
- Custom detection: Will detecting with the user draw something similar to an array of position.
How to use
Swap Gesture
import { GetSwapGesture } from "./SwapGesture";
new GetSwapGesture(app, 'left', ()=> {
//your code here
}, 200)
new GetSwapGesture(app, 'right', ()=> {
//your code here
}, 200);
new GetSwapGesture(app, 'top', ()=> {
//your code here
}, 200);
new GetSwapGesture(app, 'bot', ()=> {
//your code here
}, 200);
// Parameters
//(1) - pixi app
//(2) - (String) direction you wanna get
//(3) - (Callback)
//(4) - (int) minimun swap distance to trigger the callback
NPM install
Yes! you can import using npm
npm i pixi-gestures
import and use on your project
// SIMPLE EXAMPLE
import { GetSwapGesture } from 'pixi-gesture/dist/SwapGesture'
new GetSwapGesture(app, 'left', ()=> {
//your code here
}, 200)
new GetSwapGesture(app, 'right', ()=> {
//your code here
}, 200);
new GetSwapGesture(app, 'top', ()=> {
//your code here
}, 200);
new GetSwapGesture(app, 'bot', ()=> {
//your code here
}, 200);