@@ -523,11 +523,11 @@ var MatterPhysics = new Class({
523523 *
524524 * This plugin also extends Matter.Body with three convenience functions:
525525 *
526- * `Matter.Body.onCollide (callback)`
527- * `Matter.Body.onCollideEnd (callback)`
528- * `Matter.Body.onCollideActive (callback)`
526+ * `Matter.Body.setOnCollide (callback)`
527+ * `Matter.Body.setOnCollideEnd (callback)`
528+ * `Matter.Body.setOnCollideActive (callback)`
529529 *
530- * You can register event callbacks by providing a function of type ( pair: Matter.Pair) => void:
530+ * You can register event callbacks by providing a function of type (pair: Matter.Pair) => void
531531 *
532532 * https://github.com/dxu/matter-collision-events
533533 *
@@ -698,6 +698,114 @@ var MatterPhysics = new Class({
698698 return Query . point ( bodies , position ) ;
699699 } ,
700700
701+ /**
702+ * Sets the debug render style for the given Matter Body.
703+ *
704+ * If you are using this on a Phaser Game Object, such as a Matter Sprite, then pass in the body property
705+ * to this method, not the Game Object itself.
706+ *
707+ * If you wish to skip a value, pass `undefined` for it.
708+ * If you wish to reset a value, so it uses those set in the World Debug Config, pass `null` or `false` as the value.
709+ * All other values are considered numeric color values.
710+ *
711+ * @method Phaser.Physics.Matter.MatterPhysics#setBodyRenderStyle
712+ * @since 3.22.0
713+ *
714+ * @param {MatterJS.Body } body - The Matter Body to set the render style on.
715+ * @param {number } [lineColor] - The stroke color. Set to `null` to use the default debug config values.
716+ * @param {number } [fillColor] - The fill color. Set to `null` to use the default debug config values.
717+ * @param {number } [opacity] - The opacity, between 0 and 1. Set to `null` to use the default debug config values.
718+ * @param {number } [lineThickness] - The stroke line thickness. Set to `null` to use the default debug config values.
719+ *
720+ * @return {this } This Matter Physics instance for method chaining.
721+ */
722+ setBodyRenderStyle : function ( body , lineColor , fillColor , opacity , lineThickness )
723+ {
724+ var render = body . render ;
725+
726+ if ( render )
727+ {
728+ if ( fillColor !== undefined )
729+ {
730+ render . fillColor = fillColor ;
731+ }
732+
733+ if ( lineColor !== undefined )
734+ {
735+ render . strokeColor = lineColor ;
736+ }
737+
738+ if ( opacity !== undefined )
739+ {
740+ render . opacity = opacity ;
741+ }
742+
743+ if ( lineThickness !== undefined )
744+ {
745+ render . lineThickness = lineThickness ;
746+ }
747+ }
748+
749+ return this ;
750+ } ,
751+
752+ /**
753+ * Sets the debug render style for the given Matter Constraint.
754+ *
755+ * If you are using this on a Phaser Game Object, then pass in the body property
756+ * to this method, not the Game Object itself.
757+ *
758+ * If you wish to skip a value, pass `undefined` for it.
759+ * If you wish to reset a value, so it uses those set in the World Debug Config, pass `null` or `false` as the value.
760+ * All other values are considered numeric color values.
761+ *
762+ * @method Phaser.Physics.Matter.MatterPhysics#setConstraintRenderStyle
763+ * @since 3.22.0
764+ *
765+ * @param {MatterJS.Constraint } constraint - The Matter Constraint to set the render style on.
766+ * @param {number } [lineColor] - The line color used when rendering this constraint.
767+ * @param {number } [lineThickness] - The line thickness.
768+ * @param {number } [pinSize] - If this constraint is a pin, this sets the size of the pin circle.
769+ * @param {number } [anchorColor] - The color used when rendering this constraints anchors. Set to `null` to not render anchors.
770+ * @param {number } [anchorSize] - The size of the anchor circle, if this constraint has anchors and is rendering them.
771+ *
772+ * @return {this } This Matter Physics instance for method chaining.
773+ */
774+ setConstraintRenderStyle : function ( constraint , lineColor , lineThickness , pinSize , anchorColor , anchorSize )
775+ {
776+ var render = constraint . render ;
777+
778+ if ( render )
779+ {
780+ if ( lineColor !== undefined )
781+ {
782+ render . strokeColor = lineColor ;
783+ }
784+
785+ if ( lineThickness !== undefined )
786+ {
787+ render . lineThickness = lineThickness ;
788+ }
789+
790+ if ( pinSize !== undefined )
791+ {
792+ render . pinSize = pinSize ;
793+ }
794+
795+ if ( anchorColor !== undefined )
796+ {
797+ render . anchorColor = anchorColor ;
798+ }
799+
800+ if ( anchorSize !== undefined )
801+ {
802+ render . anchorSize = anchorSize ;
803+ }
804+ }
805+
806+ return this ;
807+ } ,
808+
701809 /**
702810 * The Scene that owns this plugin is shutting down.
703811 * We need to kill and reset all internal properties as well as stop listening to Scene events.
0 commit comments