@@ -110,7 +110,7 @@ var World = new Class({
110110 * The correction argument is an optional Number that specifies the time correction factor to apply to the update.
111111 * This can help improve the accuracy of the simulation in cases where delta is changing between updates.
112112 * The value of correction is defined as delta / lastDelta, i.e. the percentage change of delta over the last step.
113- * Therefore the value is always 1 (no correction) when delta constant (or when no correction is desired, which is the default).
113+ * Therefore the value is always 1 (no correction) when delta is constant (or when no correction is desired, which is the default).
114114 * See the paper on Time Corrected Verlet for more information.
115115 *
116116 * @name Phaser.Physics.Matter.World#correction
@@ -150,27 +150,47 @@ var World = new Class({
150150 */
151151 this . getDelta = GetValue ( config , 'getDelta' , this . update60Hz ) ;
152152
153+ var runnerConfig = GetFastValue ( config , 'runner' , { } ) ;
154+
155+ var hasFPS = GetFastValue ( runnerConfig , 'fps' , false ) ;
156+
157+ var fps = GetFastValue ( runnerConfig , 'fps' , 60 ) ;
158+
159+ var delta = GetFastValue ( runnerConfig , 'delta' , 1000 / fps ) ;
160+ var deltaMin = GetFastValue ( runnerConfig , 'deltaMin' , 1000 / fps ) ;
161+ var deltaMax = GetFastValue ( runnerConfig , 'deltaMax' , 1000 / ( fps * 0.5 ) ) ;
162+
163+ if ( ! hasFPS )
164+ {
165+ fps = 1000 / delta ;
166+ }
167+
168+ /**
169+ * The Matter JS Runner Configuration object.
170+ *
171+ * This object is populated via the Matter Configuration object's `runner` property and is
172+ * updated constantly during the game step.
173+ *
174+ * @name Phaser.Physics.Matter.World#runner
175+ * @type {Phaser.Types.Physics.Matter.MatterRunnerConfig }
176+ * @since 3.22.0
177+ */
153178 this . runner = {
154- fps : 60 ,
155- correction : 1 ,
156- deltaSampleSize : 60 ,
179+ fps : fps ,
180+ correction : GetFastValue ( runnerConfig , 'correction' , 1 ) ,
181+ deltaSampleSize : GetFastValue ( runnerConfig , 'deltaSampleSize' , 60 ) ,
157182 counterTimestamp : 0 ,
158183 frameCounter : 0 ,
159184 deltaHistory : [ ] ,
160185 timePrev : null ,
161186 timeScalePrev : 1 ,
162187 frameRequestId : null ,
163- isFixed : false ,
164- enabled : true
188+ isFixed : GetFastValue ( runnerConfig , 'isFixed' , false ) ,
189+ delta : delta ,
190+ deltaMin : deltaMin ,
191+ deltaMax : deltaMax
165192 } ;
166193
167- // var runner = Common.extend(defaults, options);
168-
169- this . runner . delta = this . runner . delta || 1000 / this . runner . fps ;
170- this . runner . deltaMin = this . runner . deltaMin || 1000 / this . runner . fps ;
171- this . runner . deltaMax = this . runner . deltaMax || 1000 / ( this . runner . fps * 0.5 ) ;
172- this . runner . fps = 1000 / this . runner . delta ;
173-
174194 /**
175195 * Automatically call Engine.update every time the game steps.
176196 * If you disable this then you are responsible for calling `World.step` directly from your game.
@@ -1055,22 +1075,18 @@ var World = new Class({
10551075 * @param {number } time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
10561076 * @param {number } delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
10571077 */
1058- OLDupdate : function ( time , delta )
1078+ update : function ( time , delta )
10591079 {
1060- if ( this . enabled && this . autoUpdate )
1080+ if ( ! this . enabled || ! this . autoUpdate )
10611081 {
1062- Engine . update ( this . engine , this . getDelta ( time , delta ) , this . correction ) ;
1082+ return ;
10631083 }
1064- } ,
10651084
1066- update : function ( time )
1067- {
10681085 var engine = this . engine ;
10691086 var runner = this . runner ;
10701087
10711088 var timing = engine . timing ;
1072- var correction = 1 ;
1073- var delta ;
1089+ var correction = this . correction ;
10741090
10751091 if ( runner . isFixed )
10761092 {
@@ -1123,16 +1139,7 @@ var World = new Class({
11231139 runner . frameCounter = 0 ;
11241140 }
11251141
1126- // Events.trigger(runner, 'tick', event);
1127-
1128- // update
1129- // Events.trigger(runner, 'beforeUpdate', event);
1130-
11311142 Engine . update ( engine , delta , correction ) ;
1132-
1133- // Events.trigger(runner, 'afterUpdate', event);
1134-
1135- // Events.trigger(runner, 'afterTick', event);
11361143 } ,
11371144
11381145 /**
0 commit comments