@@ -546,3 +546,56 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "angle", {
546546
547547} ) ;
548548
549+ /**
550+ * Render Sprite's Body.
551+ *
552+ * @method Phaser.Physics.Ninja.Body#render
553+ * @param {object } context - The context to render to.
554+ * @param {Phaser.Physics.Ninja.Body } body - The Body to render.
555+ * @param {string } [color='rgba(0,255,0,0.4)'] - color of the debug shape to be rendered. (format is css color string).
556+ * @param {boolean } [filled=true] - Render the shape as a filled (default, true) or a stroked (false)
557+ */
558+ Phaser . Physics . Ninja . Body . render = function ( context , body , color , filled ) {
559+ color = color || 'rgba(0,255,0,0.4)' ;
560+
561+ if ( typeof filled === 'undefined' )
562+ {
563+ filled = true ;
564+ }
565+
566+ if ( body . aabb )
567+ {
568+ var left = body . x - ( body . width / 2 ) - body . game . camera . x ;
569+ var top = body . y - ( body . height / 2 ) - body . game . camera . y ;
570+
571+ if ( filled )
572+ {
573+ context . fillStyle = color ;
574+ context . fillRect ( left , top , body . width , body . height ) ;
575+ }
576+ else
577+ {
578+ context . strokeStyle = color ;
579+ context . strokeRect ( left , top , body . width , body . height ) ;
580+ }
581+ }
582+ else if ( body . circle )
583+ {
584+ var x = body . x - body . game . camera . x ;
585+ var y = body . y - body . game . camera . y ;
586+
587+ context . beginPath ( ) ;
588+ context . arc ( x , y , body . circle . radius , 0 , 2 * Math . PI , false ) ;
589+
590+ if ( filled )
591+ {
592+ context . fillStyle = color ;
593+ context . fill ( ) ;
594+ }
595+ else
596+ {
597+ context . strokeStyle = color ;
598+ context . stroke ( ) ;
599+ }
600+ }
601+ } ;
0 commit comments