A lightweight virtual HTML5/Javascript mobile joystick
See a running example here: https://cptx032.github.io/virtual-joystick/
To create a virtual joystick is very simple:
// creates a centralized joystick
var joystick = new JoyStick({
radius: 80,
x: window.innerWidth / 2,
y: window.innerHeight /2,
inner_radius: 70
});
any time you want you can check the joystick status:
function check() {
requestAnimationFrame( check );
if ( joystick.up ) {
console.log( 'walk character' );
}
}
check();
This project is just for very simple projects. It is not able to say the delta and configures the button's style, for example. If you want you can checkout https://github.com/yoannmoinet/nipplejs for a more complete solution