0.4.1 • Published 3 years ago

pixi-virtual-joystick v0.4.1

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

🕹 pixi-virtual-joystick

Virtual Touch Joystick for pixi.js

Usage

import { Joystick } from "pixi-virtual-joystick";

const joystick = new Joystick({
  outer: PIXI.Sprite.from("outer"), // ("images/joystick.png")
  inner: PIXI.Sprite.from("inner"), // ("images/joystick-handle.png")

  outerScale: { x: 0.5, y: 0.5 },
  innerScale: { x: 0.8, y: 0.8 },

  onChange: (data) => {
    console.log(data.angle); // Angle from 0 to 360
    console.log(data.direction); // 'left', 'top', 'bottom', 'right', 'top_left', 'top_right', 'bottom_left' or 'bottom_right'.
    console.log(data.power); // Power from 0 to 1
  },

  onStart: () => {
    console.log('start')
  },

  onEnd: () => {
    console.log('end')
  },
});

app.stage.addChild(joystick);

Similar alternatives

License

Endel Dreyer © MIT

0.4.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.4.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago