pixel-perfect-collider
所属分类:操作系统开发
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2018-08-21 11:13:34
上 传 者:
sh-1993
说明: 像素完美碰撞检测器
(Pixel perfect collision detector)
文件列表:
.npmignore (114, 2018-08-21)
LICENSE.txt (1066, 2018-08-21)
build/ (0, 2018-08-21)
build/index.js (2852, 2018-08-21)
docs/ (0, 2018-08-21)
docs/index.css (539, 2018-08-21)
docs/index.html (853, 2018-08-21)
docs/star.png (1434, 2018-08-21)
docs/stars.gif (84358, 2018-08-21)
docs/stars.js (3607, 2018-08-21)
docs/thread.gif (697919, 2018-08-21)
docs/thread.js (570268, 2018-08-21)
package.json (1055, 2018-08-21)
src/ (0, 2018-08-21)
src/index.ts (3872, 2018-08-21)
src/samples/ (0, 2018-08-21)
src/samples/index.html (886, 2018-08-21)
src/samples/stars.ts (1591, 2018-08-21)
src/samples/thread.ts (5663, 2018-08-21)
src/samples/util/ (0, 2018-08-21)
src/samples/util/actor.ts (2411, 2018-08-21)
src/samples/util/particle.ts (2064, 2018-08-21)
src/samples/util/pointer.ts (2952, 2018-08-21)
src/samples/util/screen.ts (1987, 2018-08-21)
src/samples/util/simpleGameActor.ts (1636, 2018-08-21)
src/samples/util/star.ts (1881, 2018-08-21)
src/samples/util/text.ts (893, 2018-08-21)
src/samples/util/vector.ts (736, 2018-08-21)
tsconfig.json (126, 2018-08-21)
typings/ (0, 2018-08-21)
typings/index.d.ts (530, 2018-08-21)
webpack.config.js (1286, 2018-08-21)
# pixel-perfect-collider
Pixel perfect collision detector.
### Demo
[stars](https://abagames.github.io/pixel-perfect-collider/index.html?stars)
[![stars screenshot](https://abagames.github.io/pixel-perfect-collider/stars.gif)](https://abagames.github.io/pixel-perfect-collider/index.html?stars)
[thread](https://abagames.github.io/pixel-perfect-collider/index.html?thread)
[![stars screenshot](https://abagames.github.io/pixel-perfect-collider/thread.gif)](https://abagames.github.io/pixel-perfect-collider/index.html?thread)
### How to use
See the [sample code](https://github.com/abagames/pixel-perfect-collider/blob/master/src/samples/stars.ts).
Include [build/index.js](https://github.com/abagames/pixel-perfect-collider/blob/master/build/index.js) script,
```html
```
or install from npm.
```
> npm i pixel-perfect-collider
```
```js
import * as ppc from "pixel-perfect-collider";
```
Create `ppc.Collider` instance with a image whose collision should be detected.
```js
this.image = new Image();
this.image.src = "star.png";
this.image.onload = () => {
this.collider = new ppc.Collider(this.image);
};
```
Set the position of the collider with `Collider#setPos` function.
```js
this.collider.setPos(x, y);
```
Use `Collider#test` function to test a collision between two colliders.
```js
stars[0].collider.test(stars[1].collider);
```
近期下载者:
相关文件:
收藏者: