Libgdx box2d issue with dimensions and camera zooming

前端 未结 2 690
北荒
北荒 2021-01-14 21:56

I\'ve got a problem with Box2D. I\'m making a simple 2D game, with a player shooting to enemies. I read that 1 unity in Box2D is equivalent to 1 meter so i shou

2条回答
  •  无人及你
    2021-01-14 22:25

    Don't use PPM, i know you might have seen a lot of tutorials using PPM but instead use virtual pixels or potato pixel for camera and box2d. Here read this wonderful article and this answer. For example:

    OrthographicCamera camera = new OrthographicCamera(20, 11);
    

    Here 20 is any arbitrary number for WIDTH and HEIGHT should be actually WIDTH*Gdx.graphics.getHeight()/Gdx.graphics.getWidth(). You don't need to set any zoom level, leave it to default.

提交回复
热议问题