Back to Gdevelop

pixi-simple-gesture

newIDE/app/src/Utils/PixiSimpleGesture/README.md

5.6.2681.2 KB
Original Source

This code is a modified version of pixi-simple-gesture to work with Pixi 7.

pixi-simple-gesture

Add Pinch, Pan, Tap gesture support to pixi.js sprites.

npm install --save pixi-simple-gesture

Usage

Pan

js
var gesture = require('pixi-simple-gesture')
var inertiaMode = true

var sprite = new PIXI.Sprite(texture)
gesture.panable(sprite, inertiaMode)

sprite.on('panstart', function() {
  console.log('pan start')
})

sprite.on('panmove', function(event) {
  console.log('pan move', event)
})

sprite.on('panend', function() {
  console.log('pan end')
})

The 'panmove' handler receives an event object containing the following properties.

NameValue
deltaXMovement of the X axis
deltaYMovement of the Y axis
velocityVelocity in px/ms
dataOriginal InteractionData from pixi.js

TODO

  • Add Inertia Mode
  • Add Complex? Tap, emits 'tapstart', 'tapcancel', 'tapend'. Could be useful to implement UI components which has active state style.