Trance Posted March 26, 2018 Share Posted March 26, 2018 Does anyone know how I can get the Matter physics engine to render its geometry when running within Phaser? I.e. when I'm not assigning a sprite to a physics body, but I want the geometry of the objects I've created to be rendered as lines instead. If I set "debug" to true on the Matter config, I can see purple lines being rendered by the debugger. But if I set debug to false, I no longer see anything rendered. I've found there are a bunch of properties on the Matter "Body" object like StrokeStyle, LineWidth and FillStyle (described here) which seem designed for this purpose. However, I can't see equivalents for those in the Phaser documentation, and when I set the properties on the Matter body directly they seem to have no effect. Am I missing some simple piece of config or setup that I need to do, or have I stumbled across a bug or unsupported feature? Link to comment Share on other sites More sharing options...
PixelPicoSean Posted March 26, 2018 Share Posted March 26, 2018 The matter render system is not used in Phaser3. You can take a look at how the debug drawing work, and use graphics to draw the shape manually. Link to comment Share on other sites More sharing options...
Trance Posted March 27, 2018 Author Share Posted March 27, 2018 Damn, that's bad news. There's no way to turn it on then? Failing that, I could get away with just using the debug drawing, but even that seems broken - it works the first time I load a scene, but on subsequent occasions it doesn't draw anything. Link to comment Share on other sites More sharing options...
rich Posted March 27, 2018 Share Posted March 27, 2018 Matter.Render is not included because it's a huge file (it adds 50KB to the source), doesn't work in WebGL and, in the authors own words, was created for debugging purposes. If you want to use it then you can add the file to your own build and call it the way they do in the Matter examples, just passing in `this.matter.world` as the 'engine' property in the Render.create config object. Link to comment Share on other sites More sharing options...
Trance Posted March 27, 2018 Author Share Posted March 27, 2018 Brilliant, thanks for the pointers @rich. I hadn't realised it didn't work under WebGL, so I guess I'll have to stick to using the Debug mode. Now if only I could work out why it stops drawing anything the second time the scene is entered! Link to comment Share on other sites More sharing options...
rich Posted March 27, 2018 Share Posted March 27, 2018 My guess would be that when the Scene is left the first time, things aren’t being cleared up in the shutdown step. Be sure to kill off excess objects, bodies, etc. Link to comment Share on other sites More sharing options...
Recommended Posts