@@ -903,6 +903,30 @@ var Body = new Class({
903903 this . center . set ( this . position . x + this . halfWidth , this . position . y + this . halfHeight ) ;
904904 } ,
905905
906+ /**
907+ * Updates the Body's `position`, `width`, `height`, and `center` from its Game Object and `offset`.
908+ *
909+ * You don't need to call this for Dynamic Bodies, as it happens automatically during the physics step.
910+ * But you could use it if you have modified the Body offset or Game Object transform and need to immediately
911+ * read the Body's new `position` or `center`.
912+ *
913+ * To resynchronize the Body with its Game Object, use `reset()` instead.
914+ *
915+ * @method Phaser.Physics.Arcade.Body#updateFromGameObject
916+ * @since 3.24.0
917+ */
918+ updateFromGameObject : function ( )
919+ {
920+ this . updateBounds ( ) ;
921+
922+ var transform = this . transform ;
923+
924+ this . position . x = transform . x + transform . scaleX * ( this . offset . x - transform . displayOriginX ) ;
925+ this . position . y = transform . y + transform . scaleY * ( this . offset . y - transform . displayOriginY ) ;
926+
927+ this . updateCenter ( ) ;
928+ } ,
929+
906930 /**
907931 * Prepares the Body for a physics step by resetting the `wasTouching`, `touching` and `blocked` states.
908932 *
@@ -961,17 +985,9 @@ var Body = new Class({
961985 this . resetFlags ( ) ;
962986 }
963987
964- this . updateBounds ( ) ;
965-
966- var sprite = this . transform ;
967-
968- this . position . x = sprite . x + sprite . scaleX * ( this . offset . x - sprite . displayOriginX ) ;
969- this . position . y = sprite . y + sprite . scaleY * ( this . offset . y - sprite . displayOriginY ) ;
970-
971- this . updateCenter ( ) ;
972-
973- this . rotation = sprite . rotation ;
988+ this . updateFromGameObject ( ) ;
974989
990+ this . rotation = this . transform . rotation ;
975991 this . preRotation = this . rotation ;
976992
977993 if ( this . moves )
0 commit comments