Skip to content

Commit 4f8dd24

Browse files
committed
Handle legacy configs for now.
1 parent 2a4dadf commit 4f8dd24

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

src/physics/matter-js/World.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,40 @@ var World = new Class({
178178

179179
var debugConfig = GetValue(config, 'debug', false);
180180

181+
var drawDebug = (typeof(debugConfig) === 'object');
182+
183+
// Legacy version
184+
if (typeof(debugConfig) === 'boolean')
185+
{
186+
drawDebug = debugConfig;
187+
188+
var wireframes = GetFastValue(config, 'debugWireframes', true);
189+
190+
// Old format config - remove in a later version
191+
debugConfig = {
192+
showBody: GetFastValue(config, 'debugShowBody', true),
193+
showStaticBody: GetFastValue(config, 'debugShowStaticBody', true),
194+
showSleeping: GetFastValue(config, 'debugShowSleeping', false),
195+
showJoint: GetFastValue(config, 'debugShowJoint', true),
196+
showInternalEdges: GetFastValue(config, 'debugShowInternalEdges', false),
197+
showConvexHulls: GetFastValue(config, 'debugShowConvexHulls', false),
198+
199+
renderFill: !wireframes,
200+
renderStroke: wireframes,
201+
202+
fillColor: GetFastValue(config, 'debugBodyFillColor', 0xe3a7e3),
203+
strokeColor: GetFastValue(config, 'debugBodyColor', 0xff00ff),
204+
205+
staticFillColor: GetFastValue(config, 'debugStaticBodyColor', 0x0000ff),
206+
staticStrokeColor: GetFastValue(config, 'debugStaticBodyColor', 0x0000ff),
207+
208+
staticBodySleepOpacity: 0.5,
209+
210+
jointColor: GetFastValue(config, 'debugJointColor', 0x000000),
211+
hullColor: GetFastValue(config, 'debugConvexHullColor', 0xaaaaaa)
212+
};
213+
}
214+
181215
/**
182216
* A flag that controls if the debug graphics will be drawn to or not.
183217
*
@@ -186,7 +220,7 @@ var World = new Class({
186220
* @default false
187221
* @since 3.0.0
188222
*/
189-
this.drawDebug = (!debugConfig) ? false : true;
223+
this.drawDebug = drawDebug;
190224

191225
/**
192226
* An instance of the Graphics object the debug bodies are drawn to, if enabled.
@@ -198,10 +232,10 @@ var World = new Class({
198232
this.debugGraphic;
199233

200234
/**
201-
* The default configuration values.
235+
* The debug configuration object.
202236
*
203237
* @name Phaser.Physics.Matter.World#debugConfig
204-
* @type {object}
238+
* @type {Phaser.Types.Physics.Matter.MatterDebugConfig}
205239
* @since 3.22.0
206240
*/
207241
this.debugConfig = {

0 commit comments

Comments
 (0)