Topogram Posted September 22, 2017 Share Posted September 22, 2017 Hi, Completely new to Phaser but love it. I've purchased and am using the Box2D plugin and have a simple question about the coordinate system. If I create a new game with dimensions width 800 and height 600 like so: var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', {preload: preload, create: create, update: update, render: render}); With the following pixels to meter setting: game.physics.box2d.ptmRatio = 100; and create a new Box2D body with a 40 x 20 pixel rectangle fixture (centred on the body) like so: var rect = new Phaser.Physics.Box2D.Body(this.game, null, 400, 0); rect.static = true; rect.addRectangle(40, 20, 20, 10); See the image below: Why is the rectangle not positioned 400 pixels from the left? It looks like it's positioned 200 pixels from the left instead. Is there some scale factor I'm missing here? This is happening on my Retina MacBook Pro and on an external 1920 screen (not Retina). Many thanks in advance, Link to comment Share on other sites More sharing options...
Topogram Posted September 22, 2017 Author Share Posted September 22, 2017 After a lot of digging I think the error comes from me changing game.physics.box2d.ptmRatio to 100. If I leave it alone then things are drawn by DebugDraw correctly. If I want to set the ratio to 100 then this fixes things: game.physics.box2d.ptmRatio = 100; game.physics.box2d.debugDraw = new Phaser.Physics.Box2D.DefaultDebugDraw(100); game.physics.box2d.world.SetDebugDraw(game.physics.box2d.debugDraw); Not sure how much value I'll get from changing PTM to 100 so I'll leave it at the default for the time being... Link to comment Share on other sites More sharing options...
Recommended Posts