File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -864,5 +864,26 @@ Phaser.Point.centroid = function (points, out) {
864864
865865} ;
866866
867+ /**
868+ * Parses an object for x & y properties and returns a new Phaser.Point
869+ *
870+ * @method Phaser.Point#parse
871+ * @param {Object } obj - The object to parse
872+ * @param {string } [xProp='x'] - Optional x property name. Defaults to 'x'
873+ * @param {string } [yProp='y'] - Optional y property name. Defaults to 'y'
874+ * @return {Phaser.Point } The new Point object.
875+ * @static
876+ */
877+
878+ Phaser . Point . parse = function ( obj , xProp , yProp ) {
879+ xProp = xProp || 'x' ;
880+ yProp = yProp || 'y' ;
881+
882+ if ( obj . hasOwnProperty ( xProp ) && obj . hasOwnProperty ( yProp ) ) {
883+ return new Phaser . Point ( obj [ xProp ] , obj [ yProp ] ) ;
884+ }
885+ throw new Error ( 'Object does not contain ' + xProp + ' and ' + yProp + ' properties.' ) ;
886+ } ;
887+
867888// Because PIXI uses its own Point, we'll replace it with ours to avoid duplicating code or confusion.
868889PIXI . Point = Phaser . Point ;
You can’t perform that action at this time.
0 commit comments