npm.io
0.0.9 • Published 7 years ago

canvas-joystick

Licence
AGPLv3+
Version
0.0.9
Deps
0
Size
4 kB
Vulns
0
Weekly
0

Canvas Joystick

Usage :

const joystick = new Joystick()

// on press
const pointerPosition = { x: [number], y: [number] }
joystick.setStartPosition(pointerPosition)

// while the pointer is pressed
const pointerPosition = { x: [number], y: [number] }
joystick.setPointerPosition(pointerPosition)

// get force
const force = joystick.getAxisValues() // { x: [number], y: [number] }

// render
joystick.render()

// parameters
joystick.setScale([number])

// methods
joystick.hide()
joystick.show()

// getters
joystick.getStartPosition()
joystick.getPointerPosition()
joystick.getScale()