Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sawa-zen/zenpad.js
GamePad for canvas game.
https://github.com/sawa-zen/zenpad.js
canvas gamedev gamepad npm-package webgl
Last synced: about 1 month ago
JSON representation
GamePad for canvas game.
- Host: GitHub
- URL: https://github.com/sawa-zen/zenpad.js
- Owner: sawa-zen
- Created: 2016-06-11T03:40:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-28T11:07:54.000Z (over 6 years ago)
- Last Synced: 2024-09-29T15:21:51.110Z (about 2 months ago)
- Topics: canvas, gamedev, gamepad, npm-package, webgl
- Language: JavaScript
- Homepage:
- Size: 9.11 MB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Zenpad.js — GamePad for canvas game.
![](zenpad_demo.gif)
[![wercker status](https://app.wercker.com/status/6764b7988a279822959e792434e70223/s/master "wercker status")](https://app.wercker.com/project/byKey/6764b7988a279822959e792434e70223)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)The aim of the project is to create an easy to use gamepad library for ``.
### Demo
- [http://zendash.sawa-zen.com/](http://zendash.sawa-zen.com/)
- [http://zenpad.sawa-zen.com/demo/](http://zenpad.sawa-zen.com/demo/)### Usage
Prepare DOM for Zenpad.js.
```html
```#### Install from script
```html
var zenpad = new Zenpad('myZenpad');
// ... see below```
#### Install from require
```javascript
var Zenpad = require('zenpad.js');
var zenpad = new Zenpad('myZenpad');
// ... see below
```#### General
```javascript
zenpad.on('touchstartA', function() {
console.info('touchstartA');
});zenpad.on('moveStick', function(event) {
console.info('moveStick', event.x);
});
```### Method
- **on(eventName:String, handler:Function)**
Use to add events.
- **off(eventName:String, handler:Function)**
Use to remove events.
- **dispose()**
Use to dispose zenpad.
### Event
- **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.