pixi-analog-stick

1.0.12 • Public • Published

pixi-analog-stick

The aim of the project is to create an easy to use analog stick library for PIXI.js.

capture

MIT License

Install

$ npm install --save pixi-analog-stick

Usage

import * as PIXI from 'pixi.js';
import PixiAnalogStick from 'pixi-analog-stick';
 
class Container extends PIXI.Container {
  constructor() {
    super();
 
    // AnalogStick
    this._analogStick = new PixiAnalogStick();
    this._analogStick.on('move', this._onMoveStick);
    this._analogStick.on('release', this._onReleaseStick);
    this.addChild(this._analogStick);
  }
 
  _onMoveStick = (stickData) => {
    console.info('move', stickData);
  };
 
  _onReleaseStick = () => {
    console.info('release', stickData);
  };
}
 
export default Container;

Method

  • on(eventName:String, handler:Function)

    Use to add events.

  • off(eventName:String, handler:Function)

    Use to remove events.

  • reset()

    Reset stick position.

  • dispose()

    Use to dispose pixi-analog-stick.

Event

  • move

    Emit "move" event when move stick.

    Property

    • x : It is "x" position of stick.
    • y : It is "y" position of stick.
    • angle : It is the angle where the stick was knocked down.
    • length : It is the distance between the stick and the center.
  • release

    Emit "release" event when stick is released.

Package Sidebar

Install

npm i pixi-analog-stick

Weekly Downloads

1

Version

1.0.12

License

MIT

Unpacked Size

7.11 MB

Total Files

5

Last publish

Collaborators

  • sawa-zen