🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

hitarea-shapes

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hitarea-shapes

PixiJS hitArea with multiple polygons.

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
12
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

forthebadge forthebadge forthebadge

HitAreaShapes

Use PixiJS to set shape's hitArea with multiple polygons. This library prevents hitarea from acting on transparent pixels.

In order to use the shape tracer to get the coordinates of the polygon, please install PhysicsEditor.

Demo

👉 Online Code Demo

demo

Prepare

  • Download PhysicsEditor.

  • Add sprite
    image

  • Use shape tracer.
    image

  • Select Phaser(P2) from Exporter menu.
    image

  • Publish image with JSON format.
    image

*. Read More: PhysicsEditor Documentation

Installation

Use cdn

<script src="https://unpkg.com/hitarea-shapes"></script>

Use npm

npm install --save pixi.js hitarea-shapes

Use yarn

yarn add pixi.js hitarea-shapes

Example

Import module and your polygons json file.

import HitAreaShapes from 'hitarea-shapes';
import polygons from './my-polygons.json';

const hitAreaShapes = new HitAreaShapes(polygons);

// flowerTop.png is a 119x181 rectangle
const sprite = PIXI.Sprite.from('https://pixijs.io/examples/examples/assets/flowerTop.png');

sprite.buttonMode = true;
sprite.interactive = true;

sprite.hitArea = hitAreaShapes;

Credit

Generator

This library generated by webpack-library-starter.

License

MIT

Keywords

pixijs

FAQs

Package last updated on 06 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts