Skip to content

cptx032/virtual-joystick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published