Libgdx box2d issue with dimensions and camera zooming

前端 未结 2 692
北荒
北荒 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:01

    you don't have to use the zoom to handle this here what i do and it works very well for me

    camera = new OrthographicCamera(SCREEN_WIDTH/PPM, Config.SCREEN_HEIGHT/PPM);
    
    // fix camera to the center of the screen
    camera.position.set(Config.SCREEN_WIDTH/PPM/2f, Config.SCREEN_HEIGHT/PPM/2f, 0);
    
    camera.update();
    

    i put the conversion unit (PPM) to 100

    hope this was helpful

    Good luck

提交回复
热议问题