/virtual-joystick

HTML5/Javascript mobile joystick

Primary LanguageJavaScriptCreative Commons Zero v1.0 UniversalCC0-1.0

virtual-joystick

A lightweight virtual HTML5/Javascript mobile joystick

Virtual 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();

Limitations

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