j.c Posted November 12, 2018 Share Posted November 12, 2018 actually I have done this, but with the unit transformation issue, I need to find a best way to refactor my existing code. as you know box2d unit is meter, game unit is pixel, so when you create box2d Bodies you need to use a fixed factor you specified for example 100px = 1meter, so they are in the game world is really small for example a basketball is 0.3meter (30cm), the corresponding pixel should be 330px but if you don't scale your game world up it will be displayed as 0.3px , to scale game world bigger is very easy in Phaser3, there are a few ways to do that, like directly set camera.zoom etc. now another problem comes, I don't need my basketball in the game looks so big, if in pure GL code I can use gluOrtho2D to fix my display proper. so how can I achieve this in Phaser 3? Link to comment Share on other sites More sharing options...
j.c Posted November 12, 2018 Author Share Posted November 12, 2018 @rich do you have any suggestions on this? thanks. Link to comment Share on other sites More sharing options...
j.c Posted November 12, 2018 Author Share Posted November 12, 2018 refer to post also: https://stackoverflow.com/questions/28028121/how-many-pixels-is-a-meter-in-box2d Link to comment Share on other sites More sharing options...
j.c Posted November 13, 2018 Author Share Posted November 13, 2018 my current thought is to write a customized pipeline that handles all things related to coordinate and size scaling, and then finally use camera to zoom in the screen. don't know if this is a 'good' way? @rich Link to comment Share on other sites More sharing options...
1p0 Posted November 19, 2018 Share Posted November 19, 2018 @j.c a working example, you may find the answer in the factors inside: http://lo-th.github.io/crossed/phy_b2d.html click the github fork me on top to see and clone the whole repository. The content of that particular example on pixi box2d is this one: https://github.com/lo-th/crossed/blob/gh-pages/phy_b2d.html It's an old version but check the function update() { ... } Link to comment Share on other sites More sharing options...
j.c Posted November 23, 2018 Author Share Posted November 23, 2018 @1p0thanks man, I finally use PTM to scale & sync position with my sprites in the frame update. so the box2d variables can stay the same always. 1p0 1 Link to comment Share on other sites More sharing options...
Recommended Posts