joystick-kit

1.0.6ย โ€ขย Publicย โ€ขย Published

joystick

๐ŸŽฎ Virtual joystick ่™šๆ‹Ÿๆ‘‡ๆ†


install

pnpm add joystick-kit

dome

import Joystick from "joystick-kit";

/*  create instance */
const joystick = new Joystick();

/*  create joystick */
joystick.create({ zone: "joystick" });

/* event */
joystick.on("start", () => {
  console.log("start ===> ");
});

API

create

interface CreateConfig {
  mode: string; // ๆŒ‚่ฝฝๆจกๅผ static | dynamic
  zone: string; // ๆŒ‚่ฝฝ่Š‚็‚น
  size?: number; // ๆ‘‡ๆ†ๅคงๅฐ
  position: { top: string; left: string; right: string; bottom: string }; //็ป„ไปถๅฎšไฝ dynamic ๆจกๅผไธ‹ๆ— ๆ•ˆ
  color?: { back: string; front: string }; // ๆ‘‡ๆ†้ขœ่‰ฒ
  backImg?: { back: string; front: string }; // ๆ‘‡ๆ†่ƒŒๆ™ฏๅ›พ
}

backImg ไผ˜ๅ…ˆไบŽ color


on

// event keys
interface EventType {
  start: string;
  move: string;
  end: string;
}

//  event params
interface MoveInfo {
  direction: string;
  ang: number;
}
interface EventObj {
  start: null | ((Event, Joystick) => void);
  move: null | ((Event, { direction, ang }: MoveInfo) => void);
  end: null | ((Event, Joystick) => void);
}

็ฑปๅž‹ๅ‚่€ƒ

Package Sidebar

Install

npm i joystick-kit

Weekly Downloads

8

Version

1.0.6

License

ISC

Unpacked Size

55.5 kB

Total Files

16

Last publish

Collaborators

  • wanpan_11