eva-engine / eva.js

Eva.js is a front-end game engine specifically for creating interactive game projects.
https://eva.js.org
MIT License
1.75k stars 108 forks source link

Adding polygon body for Matterjs plugin. #57

Closed fanmingfei closed 3 years ago

fanmingfei commented 3 years ago

Polygon have two type, regular polygon and irregular polygon.

In Matter.js, create regular polygon use Matter.Bodies.polygon. create irregular polygon can use Matter.Vertices.create(points, body) or Matter.Svg.

Step1: Add a PhysicsType: https://github.com/eva-engine/eva.js/blob/dba678ea595aea6ea946501229d24ed2324551f2/packages/plugin-matterjs/lib/Physics.ts#L3

Step2: Create Body with polygon, vertices or svg. https://github.com/eva-engine/eva.js/blob/dba678ea595aea6ea946501229d24ed2324551f2/packages/plugin-matterjs/lib/BodiesFactory.ts#L33

fanmingfei commented 3 years ago

regular polygon: #61

fanmingfei commented 3 years ago

regular polygon are supported when needed.