n00b here so please excuse my lack of terminology, How do I make an irregular polygon with this style of code?

this.matter.add.rectangle(100, 300, 30, 400);
this.matter.add.circle(125, 200, 40);
this.matter.add.polygon(150, 10, 5, 30);

Those are examples of some working closed shapes in my page. I tried adding pairs of x,y coordinates but the page fails, I’m not even sure if .polygon is the element name I need, I tried .points but I’m such a n00b, I could have gotten the element type, bracket types, or commas wrong etc? Here is my page so far:

https://www.rhgrafix.com/SlicePhysics.htm  which has these externals:
https://www.rhgrafix.com/js/game.js 
https://www.rhgrafix.com/js/phaser.js 
https://www.rhgrafix.com/js/polyk.js 

I see that the elements get set up in phaser.js, but the code syntax is confusing, all the tutorials have a different syntax style than what I have. My page based on this demo by Emanuele Feronato https://www.emanueleferonato.com/wp-content/uploads/2019/03/slice/
My goal is to draw a simple outline of an anvil and slice it up, and hopefully learn how to color each shape outline a different color and fill them with color and hope it still slices up .I have a feeling that it may have to be made from primitive shapes in a group, as long as it doesn’t fall apart and can be sliced with polyk.js I’m happy. Thanks much! R.L. Hamm

0 Answers