The aim of the project is to create an easy to use gamepad library for <canvas>
.
Prepare DOM for Zenpad.js.
<div id="myZenpad"></div>
<script src="zenpad.js"></script>
<script>
var zenpad = new Zenpad('myZenpad');
// ... see below
</script>
var Zenpad = require('zenpad.js');
var zenpad = new Zenpad('myZenpad');
// ... see below
zenpad.on('touchstartA', function() {
console.info('touchstartA');
});
zenpad.on('moveStick', function(event) {
console.info('moveStick', event.x);
});
-
on(eventName:String, handler:Function)
Use to add events.
-
off(eventName:String, handler:Function)
Use to remove events.
-
dispose()
Use to dispose zenpad.
-
touchstartA
Emit "touchstartA" event when push "A" button.
-
touchendA
Emit "touchendA" event when pull "A" button.
-
clickA
This is "touchendA" alias event.
-
touchstartB
Emit "touchstartB" event when push "B" button.
-
touchendB
Emit "touchendB" event when pull "B" button.
-
clickB
This is "touchendB" alias event.
-
moveStick
Emit "moveStick" event when move stick.
Property
- x : It is "x" position of stick.
- y : It is "y" position of stick.
- angle : It is the angle where the stick was knocked down.
- length : It is the distance between the stick and the center.
-
releaseStick
Emit "releaseStick" event when stick is released.